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
+29-42Lines changed: 29 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,16 @@
6
6
7
7
8
8
`Atributika` is a Swift library that provides a simple way to build NSAttributedString from HTML-like text, by identifying and styling tags, links, phone numbers, hashtags, and so on.
9
+
9
10
A standalone `AtributikaViews` library offers UILabel/UITextView drop-in replacements capable of displaying highlightable and clickable links, rich customization, and solid accessibility support.
10
11
11
-
## Introduction
12
-
While NSAttributedString is undoubtedly powerful, it's also a low-level API that demands a considerable amount of setup work. If your string is a template and the actual content is only known at runtime, this becomes particularly tedious. When dealing with localizations, constructing NSAttributedString isn't straightforward either.
12
+
## Intro
13
+
While NSAttributedString is undoubtedly powerful, it's also a low-level API that demands a considerable amount of setup work. If your string is a template and the actual content is only known at runtime, this becomes complicated. When dealing with localizations, constructing NSAttributedString isn't straightforward either.
13
14
14
15
But wait, `Atributika` comes to your rescue!
15
16
16
17
```swift
17
-
let b = Attrs.font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
18
+
let b =Attrs().font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
@@ -111,7 +112,7 @@ let str = "Check this website http://google.com"
111
112
112
113
```swift
113
114
let str ="Call me (888)555-5512"
114
-
.stylePhoneNumbers(Attrs.foregroundColor(.red))
115
+
.stylePhoneNumbers(Attrs().foregroundColor(.red))
115
116
.attributedString
116
117
```
117
118
@@ -120,38 +121,26 @@ let str = "Call me (888)555-5512"
120
121
### Uber String
121
122
122
123
```swift
123
-
let links = Attrs.foregroundColor(.blue)
124
-
let phoneNumbers = Attrs.backgroundColor(.yellow)
125
-
let mentions = Attrs.font(.italicSystemFont(ofSize: 12)).foregroundColor(.black)
126
-
let b = Attrs.font(.boldSystemFont(ofSize: 12))
127
-
let u = Attrs.underlineStyle(.single)
128
-
129
-
let base = Attrs.font(.systemFont(ofSize: 12)).foregroundColor(.gray)
130
-
131
-
let str ="@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
132
-
.style(tags: ["u": u, "b": b])
133
-
.styleMentions(mentions)
134
-
.styleHashtags(links)
135
-
.styleLinks(links)
136
-
.stylePhoneNumbers(phoneNumbers)
137
-
.styleBase(base)
138
-
.attributedString
139
-
140
-
return str
124
+
let links =Attrs().foregroundColor(.blue)
125
+
let phoneNumbers =Attrs().backgroundColor(.yellow)
126
+
let mentions =Attrs().font(.italicSystemFont(ofSize: 12)).foregroundColor(.black)
127
+
let b =Attrs().font(.boldSystemFont(ofSize: 12))
128
+
let u =Attrs().underlineStyle(.single)
129
+
130
+
let base =Attrs().font(.systemFont(ofSize: 12)).foregroundColor(.gray)
131
+
132
+
let str ="@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
`AttributedLabel` displays `NSAttributedString` and makes links clickable. Links needs to be added as attribute using `.attributedLabelLink` key. Value for this key can be of any type, conventional builder using String.
0 commit comments