.color(.red), .lineHeightMultiple(0.7), .alignment(.center), .tracking(.point(15)) ) let string = "Swift Office Hours".styled(with: style) label.attributedText = string Swift Office Hours ¶ NSAttributedString is hard to use easy
.color(.red), .lineHeightMultiple(0.7), .alignment(.center), .tracking(.adobe(1000)) ) let string = "Swift Office Hours".styled(with: style) label.attributedText = string ¶ NSAttributedString is hard to use easy Swift Office Hours
.color(.red), .lineHeightMultiple(0.7), .alignment(.center), .tracking(.adobe(1000)), .numberSpacing(.monospaced), .numberCase(.upper) ) let string = "Swift Office Hours".styled(with: style) label.attributedText = string ¶ NSAttributedString is hard to use easy Swift Office Hours
NSTextAttachment() attachment.image = attachment.bounds = CGRect(origin: .zero, size: myImage.size) let imageString = NSAttributedString(attachment: attachment) let fullString = NSMutableAttributedString(string: " Office Hours") fullString.insert(imageString, at: 0) UNCAUGHT EXCEPTION (NSInvalidUnarchiveOperationException): *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (UIImage) for key (NS.image); the class may be defined in source code or a library that is not linked swift Office Hours
NSTextAttachment() attachment.image = attachment.bounds = CGRect(origin: .zero, size: myImage.size) let imageString = NSAttributedString(attachment: attachment) let fullString = NSMutableAttributedString(string: " Office Hours") fullString.insert(imageString, at: 0) UNCAUGHT EXCEPTION (NSInvalidUnarchiveOperationException): *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (UIImage) for key (NS.image); the class may be defined in source code or a library that is not linked rdar://30605012 swift Office Hours
it’s the result of years of research that have shown coupling between data and presentation to be ideal. @hyperspacemark Mark Adams ¶ Hard to style ranges of strings
"I went to Swift Office Hours, and it was <strong>not</strong> too cold!" let strong = StringStyle( .font(myBoldFont) ) let style = StringStyle( .font(myNormalFont), .xmlRules([ .style("strong", strong), ])) Trivial
"I went to Swift Office Hours, and it was <strong>not</strong> too cold!" let strong = StringStyle( .font(myBoldFont) ) let style = StringStyle( .font(myNormalFont), .xmlRules([ .style("strong", strong), ])) let attributed = string.styled(with: style) Trivial
"Je suis allé à Swift Office Hours, et il <strong>n’</strong>était <strong>pas</strong> trop froid!" let strong = StringStyle( .font(myBoldFont) ) let style = StringStyle( .font(myNormalFont), .xmlRules([ .style("strong", strong), ])) let attributed = string.styled(with: style) Trivial
// U+00A0: no-break space let test = "Swift\u{00A0}Office\u{00A0}Hours" XCTAssertEqual(test, "Swift Office Hours") } ("Swift Office Hours") is not equal to ("Swift Office Hours")
let string = "Swift<BON:noBreakSpace/>Office<BON:noBreakSpace/>Hours" let attributed = string.styled(with: .xmlRules([])) let test = attributed.bonMotDebugString painless
let string = "Swift<BON:noBreakSpace/>Office<BON:noBreakSpace/>Hours" let attributed = string.styled(with: .xmlRules([])) let test = attributed.bonMotDebugString XCTAssertEqual(test, "Swift Office Hours") } painless
let string = "Swift<BON:noBreakSpace/>Office<BON:noBreakSpace/>Hours" let attributed = string.styled(with: .xmlRules([])) let test = attributed.bonMotDebugString XCTAssertEqual(test, "Swift Office Hours") } painless ("Swift<BON:noBreakSpace/>Office<BON:noBreakSpace/>Hours") is not equal to ("Swift Office Hours")
to use ¶ Hard to wrap images with text ¶ Hard to style ranges of strings ¶ Special characters are hard to read painless Trivial Surprisingly easy Predictable-ish easy
to use ¶ Hard to wrap images with text ¶ Hard to style ranges of strings ¶ Special characters are hard to read ¶ Dynamic Type API is limited rad painless Trivial Surprisingly easy Predictable-ish easy
color: BONColor? var underline: (NSUnderlineStyle, BONColor?)? var strikethrough: (NSUnderlineStyle, BONColor?)? var baselineOffset: CGFloat? var lineSpacing: CGFloat? var paragraphSpacingAfter: CGFloat? var alignment: NSTextAlignment? var firstLineHeadIndent: CGFloat? var lineHeightMultiple: CGFloat? // ✂ snip 40 lines var numberCase: NumberCase? var numberSpacing: NumberSpacing? var tracking: Tracking? } StringStyle (360 lines)
case font(BONFont) case backgroundColor(BONColor) case color(BONColor) case underline(NSUnderlineStyle, BONColor?) case strikethrough(NSUnderlineStyle, BONColor?) case baselineOffset(CGFloat) case alignment(NSTextAlignment) case tracking(Tracking) case lineSpacing(CGFloat) case paragraphSpacingAfter(CGFloat) case firstLineHeadIndent(CGFloat) case numberSpacing(NumberSpacing) case numberCase(NumberCase) case fractions(Fractions) // ✂ snip many lines } }
Olivier Halligon’s OHHTTPStubs. ¶ Write as though you’re targeting 3.0. ¶ Where possible, first arguments should have argument labels. https://www.raizlabs.com/dev/2016/10/swift-2-x-3-0-compatibility/
Olivier Halligon’s OHHTTPStubs. ¶ Write as though you’re targeting 3.0. ¶ Where possible, first arguments should have argument labels. ¶ Backfill Swift 3-style method names in Swift 2.x extensions. https://www.raizlabs.com/dev/2016/10/swift-2-x-3-0-compatibility/