You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-38Lines changed: 40 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Created by <b>Daniele Margutti</b> - <a href="http://www.danielemargutti.com">da
14
14
15
15
SwiftRichString is a lightweight library which allows to create and manipulate attributed strings easily both in iOS, macOS, tvOS and even watchOS.
16
16
It provides convenient way to store styles you can reuse in your app's UI elements, allows complex tag-based strings rendering and also includes integration with Interface Builder.
17
+
It even support iOS 11's Dynamic Type!
17
18
18
19
If you manipulate `NSAttributedString` in Swift, SwiftRichString allows you to keep your code manteniable, readable and easy to evolve.
SwiftRichString allows you to simplify string concatenation by providing custom `+` operator between `String`,`AttributedString` (typealias of `NSMutableAttributedString`) and `Style`.
231
196
@@ -399,6 +364,27 @@ let style = Style {
399
364
}
400
365
```
401
366
367
+
<a name="dynamicattributes"/>
368
+
369
+
### Dynamic Attributes from Tag's Params
370
+
371
+
SwiftRichString also support some dynamic elements in style applied by reading specific tag parameter's value.
372
+
The following example render the `linkURL` property by reading the value from the source string inside `href` tag (like in real HTML text):
373
+
374
+
```
375
+
let normal =Style {
376
+
$0.color= UIColor.black
377
+
}
378
+
let link =Style {
379
+
$0.color= UIColor.red
380
+
$0.linkURL= URLRepresentable.tagAttribute("href")
381
+
}
382
+
let group = StyleGroup.init(base: normal, ["a": link])
383
+
384
+
let bodyHTML ="Go to <a href=\"http://www.apple.com\">Apple</a> web site!"
0 commit comments