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
+16-36Lines changed: 16 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,19 @@
10
10
SwiftRichString is a lightweight library which allows to create and manipulate attributed strings easily both in iOS, macOS, tvOS and even watchOS.
11
11
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.
12
12
13
-
It even support **iOS 11's Dynamic Type**!
13
+
## Main Features
14
14
15
-
If you manipulate `NSAttributedString` in Swift, SwiftRichString allows you to keep your code manteniable, readable and easy to evolve.
| 🏞 | Attach local and remote images inside text |
19
+
| 🧬 | Fast & high customizable XML/HTML tagged string rendering |
20
+
| 🌟 | Apply text transforms within styles |
21
+
| 📐 | Native support for iOS 11 Dynamic Type |
22
+
| ⏱ | Compact code base with no external dependencies. |
23
+
| 🐦 | Fully made in Swift 5 from Swift ❥ lovers |
16
24
17
-
## Features Highlights
18
-
19
-
Want to know what SwiftRichString can do in your app? Lets take a look to these feature highlights!
20
-
21
-
### 1. Easy Styling
22
-
The main concept behind this lib is the `Style`: a style is just a collection of text attributes you can apply to a string. The following example show how to create a style an produce an attributed string with it:
25
+
### Easy Styling
23
26
24
27
```swift
25
28
let style =Style {
@@ -31,20 +34,7 @@ let style = Style {
31
34
let attributedText ="Hello World!".set(style: style) // et voilà!
32
35
```
33
36
34
-
### 2. Global Styles & Interface Builder Integration
35
-
Styles can be also registered globally and reused in your app.
36
-
Just define your own style and register using `Styles.register()` function:
37
-
38
-
```swift
39
-
let myStyle =Style { // define style's attributes... }
40
-
Styles.register("MyStyle", style: style)
41
-
```
42
-
43
-
Now you can reuse it everything in your app; SwiftRichString exposes a `styleName` property for the most common text containers and you can set it directly in Interface Builder:
SwiftRichString allows you to render complex strings by parsing text's tags: each style will be identified by an unique name (used inside the tag) and you can create a `StyleGroup` which allows you to encapsulate all of them and reuse as you need (clearly you can register it globally).
49
39
50
40
```swift
@@ -64,10 +54,7 @@ let italic = normal.byAdding {
64
54
$0.traitVariants= .italic
65
55
}
66
56
67
-
// Create a group which contains your style, each identified by a tag.
68
57
let myGroup =StyleGroup(base: normal, ["bold": bold, "italic": italic])
69
-
70
-
// Use tags in your plain string
71
58
let str ="Hello <bold>Daniele!</bold>. You're ready to <italic>play with us!</italic>"
0 commit comments