Skip to content

Commit 76368df

Browse files
Pavel Sharandapsharanda
authored andcommitted
Update README.md
1 parent db594d2 commit 76368df

File tree

1 file changed

+29
-42
lines changed

1 file changed

+29
-42
lines changed

README.md

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77

88
`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+
910
A standalone `AtributikaViews` library offers UILabel/UITextView drop-in replacements capable of displaying highlightable and clickable links, rich customization, and solid accessibility support.
1011

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.
1314

1415
But wait, `Atributika` comes to your rescue!
1516

1617
```swift
17-
let b = Attrs.font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
18+
let b = Attrs().font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
1819

1920
label.attributedText = "Hello <b>World</b>!!!".style(tags: ["b": b]).attributedString
2021
```
@@ -71,11 +72,11 @@ New examples have been added to the Demo application, including:
7172

7273
```swift
7374
let redColor = UIColor(red:(0xD0 / 255.0), green: (0x02 / 255.0), blue:(0x1B / 255.0), alpha:1.0)
74-
let a = Attrs.foregroundColor(redColor)
75+
let a = Attrs().foregroundColor(redColor)
7576

7677
let font = UIFont(name: "AvenirNext-Regular", size: 24)!
7778
let grayColor = UIColor(white: 0x66 / 255.0, alpha: 1)
78-
let base = Attrs.font(font).foregroundColor(grayColor)
79+
let base = Attrs().font(font).foregroundColor(grayColor)
7980

8081
let str = "<a>&lt;a&gt;</a>tributik<a>&lt;/a&gt;</a>"
8182
.style(tags: ["a": a])
@@ -89,8 +90,8 @@ let str = "<a>&lt;a&gt;</a>tributik<a>&lt;/a&gt;</a>"
8990

9091
```swift
9192
let str = "#Hello @World!!!"
92-
.styleHashtags(Attrs.font(.boldSystemFont(ofSize: 45)))
93-
.styleMentions(Attrs.foregroundColor(.red))
93+
.styleHashtags(Attrs().font(.boldSystemFont(ofSize: 45)))
94+
.styleMentions(Attrs().foregroundColor(.red))
9495
.attributedString
9596
```
9697

@@ -101,7 +102,7 @@ let str = "#Hello @World!!!"
101102

102103
```swift
103104
let str = "Check this website http://google.com"
104-
.styleLinks(Attrs.foregroundColor(.blue))
105+
.styleLinks(Attrs().foregroundColor(.blue))
105106
.attributedString
106107
```
107108

@@ -111,7 +112,7 @@ let str = "Check this website http://google.com"
111112

112113
```swift
113114
let str = "Call me (888)555-5512"
114-
.stylePhoneNumbers(Attrs.foregroundColor(.red))
115+
.stylePhoneNumbers(Attrs().foregroundColor(.red))
115116
.attributedString
116117
```
117118

@@ -120,38 +121,26 @@ let str = "Call me (888)555-5512"
120121
### Uber String
121122

122123
```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"
133+
.style(tags: ["u": u, "b": b])
134+
.styleMentions(mentions)
135+
.styleHashtags(links)
136+
.styleLinks(links)
137+
.stylePhoneNumbers(phoneNumbers)
138+
.styleBase(base)
139+
.attributedString
141140
```
142141

143142
<img src="https://raw.githubusercontent.com/psharanda/Atributika/master/README/test_uber.png" alt="" width="342" />
144143

145-
## Attributes / Attrs
146-
147-
## AttributedStringBuilder
148-
149-
## AttributesProvider
150-
151-
## TagTuning
152-
153-
## DetectionTuning
154-
155144
## AttributedLabel
156145
`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.
157146

@@ -202,17 +191,15 @@ view.addSubview(tweetLabel)
202191
```
203192
<img src="https://raw.githubusercontent.com/psharanda/Atributika/master/README/test_attributedlabel.png" alt="" width="361" />
204193

205-
## Demo
206-
207194
## Requirements
208195

209196
Current version is compatible with:
210197

211198
* Swift 5.0+
212-
* iOS 9.0 or later
213-
* tvOS 9.0 or later
199+
* iOS 11.0 or later
200+
* tvOS 11.0 or later
214201
* watchOS 2.0 or later
215-
* macOS 10.10 or later
202+
* macOS 10.13 or later
216203

217204
Note: `AttributedLabel` / `AttributedTextView` are available only on iOS
218205

0 commit comments

Comments
 (0)