diff --git a/README.md b/README.md index cb220cf..017b4d7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Create framework $ carthage update --platform iOS ``` -## Usage +## Example ```swift textView.attributedText = "SwiftyAttributedString" @@ -43,16 +43,37 @@ textView.attributedText = "SwiftyAttributedString" range: .portion(of: .string("Attributed")))) ``` - - ```swift -textView.attributedText = "sample text" - .add(attributes: [Attribute(value: .strikethroughStyle(1.0), - range: .portion(of: .string("sample"))), - Attribute(value: .underlineStyle(1.0), - range: .portion(of: .string("text")))]) +textView.attributedText = "SwiftyAttributedString" + .add(attributes: [Attribute(value: .font(.systemFont(ofSize: 16))), + Attribute(value: .font(.boldSystemFont(ofSize: 16)), + range: .portion(of: .string("String"))), + Attribute(value: .foregroundColor(.blue), + range: .portion(of: .string("Swifty"))), + Attribute(value: .foregroundColor(.red), + range: .portion(of: .string("Attributed"))), + Attribute(value: .foregroundColor(.orange), + range: .portion(of: .string("String"))), + Attribute(value: .underlineStyle(1.0), + range: .portion(of: .string("Attributed")))]) ``` - - + +## References +| Dictionary Key | Attributed Value | +| ----------------------------------------------| --------------------------------------------------- | +| `NSFontAttributeName` | `.font(UIFont)` | +| `NSForegroundColorAttributeName` | `.foregroundColor(UIColor)` | +| `NSBackgroundColorAttributeName` | `.backgroundColor(UIColor)` | +| `NSKernAttributeName` | `.kern(NSNumber)` | +| `NSStrikethroughStyleAttributeName` | `.strikethroughStyle(NSNumber)` | +| `NSUnderlineStyleAttributeName` | `.underlineStyle(NSNumber)` | +| `NSStrokeColorAttributeName` | `.strokeColor(UIColor)` | +| `NSStrokeWidthAttributeName` | `.strokeWidth(NSNumber)` | +| `NSShadowAttributeName` | `.shadow(NSShadow)` | +| `NSTextEffectAttributeName` | `.textEffect(SwiftyAttributedString.TextEffect)` | +| `NSLinkAttributeName` | `.link(URL)` | +| `NSBaselineOffsetAttributeName` | `.baselineOffset(NSNumber)` | +| `NSObliquenessAttributeName` | `.obliqueness(NSNumber)` | +| `NSExpansionAttributeName` | `.expansion(NSNumber)` |