### CocoaPods Integration
Source: https://github.com/psharanda/atributika/blob/master/README.md
Install Atributika and its associated views using CocoaPods by adding the respective pod lines to your Podfile.
```ruby
pod "Atributika"
pod "AtributikaViews"
```
--------------------------------
### Basic Tag Styling
Source: https://github.com/psharanda/atributika/blob/master/README.md
Applies a bold font and red foreground color to the 'b' tag within a string. This is a fundamental example of styling specific tags.
```swift
let b = Attrs().font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
label.attributedText = "Hello World!!!".style(tags: ["b": b]).attributedString
```
--------------------------------
### Styling Strings with Atributika
Source: https://github.com/psharanda/atributika/blob/master/README.md
Demonstrates how to apply various styles like foreground color, background color, font, and underline to different parts of a string using Atributika's Attrs and style methods.
```swift
let links = Attrs().foregroundColor(.blue)
let phoneNumbers = Attrs().backgroundColor(.yellow)
let mentions = Attrs().font(.italicSystemFont(ofSize: 12)).foregroundColor(.black)
let b = Attrs().font(.boldSystemFont(ofSize: 12))
let u = Attrs().underlineStyle(.single)
let base = Attrs().font(.systemFont(ofSize: 12)).foregroundColor(.gray)
let str = "@all I found really nice framework to manage attributed strings. It is called Atributika. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
.style(tags: ["u": u, "b": b])
.styleMentions(mentions)
.styleHashtags(links)
.styleLinks(links)
.stylePhoneNumbers(phoneNumbers)
.styleBase(base)
.attributedString
```
--------------------------------
### Swift Package Manager Integration
Source: https://github.com/psharanda/atributika/blob/master/README.md
Add Atributika as a dependency to your project using Swift Package Manager by specifying the repository URL and version constraint in your Package.swift file.
```swift
dependencies: [
.package(url: "https://github.com/psharanda/Atributika.git", .upToNextMajor(from: "5.0.0"))
]
```
--------------------------------
### Styling Links
Source: https://github.com/psharanda/atributika/blob/master/README.md
Styles detected URLs within a string with a blue foreground color, making them visually distinct and clickable. This is useful for presenting web addresses.
```swift
let str = "Check this website http://google.com"
.styleLinks(Attrs().foregroundColor(.blue))
.attributedString
```
--------------------------------
### Styling Tags with Base Style and HTML Symbols
Source: https://github.com/psharanda/atributika/blob/master/README.md
Styles specific HTML-like tags with a custom foreground color and applies a base font and color to the rest of the string. It also correctly handles HTML entities like '<' and '>'.
```swift
let redColor = UIColor(red:(0xD0 / 255.0), green: (0x02 / 255.0), blue:(0x1B / 255.0), alpha:1.0)
let a = Attrs().foregroundColor(redColor)
let font = UIFont(name: "AvenirNext-Regular", size: 24)!
let grayColor = UIColor(white: 0x66 / 255.0, alpha: 1)
let base = Attrs().font(font).foregroundColor(grayColor)
let str = "<a>tributik</a>"
.style(tags: ["a": a])
.styleBase(base)
.attributedString
```
--------------------------------
### Styling Hashtags and Mentions
Source: https://github.com/psharanda/atributika/blob/master/README.md
Applies distinct styles to hashtags (bold font) and mentions (red foreground color) within a string. This demonstrates the library's ability to identify and style these common patterns.
```swift
let str = "#Hello @World!!!"
.styleHashtags(Attrs().font(.boldSystemFont(ofSize: 45)))
.styleMentions(Attrs().foregroundColor(.red))
.attributedString
```
--------------------------------
### Using AttributedLabel for Styled Text
Source: https://github.com/psharanda/atributika/blob/master/README.md
Shows how to use the AttributedLabel to display styled text, including custom link handling for tags, hashtags, mentions, and general links. This snippet requires UIKit.
```swift
let tweetLabel = AttributedLabel()
tweetLabel.numberOfLines = 0
tweetLabel.highlightedLinkAttributes = Attrs().foregroundColor(.red).attributes
let baseLinkAttrs = Attrs().foregroundColor(.blue)
let a = TagTuner {
Attrs(baseLinkAttrs).akaLink($0.tag.attributes["href"] ?? "")
}
let hashtag = DetectionTuner {
Attrs(baseLinkAttrs).akaLink("https://twitter.com/hashtag/",$0.text.replacingOccurrences(of: "#", with: ""))
}
let mention = DetectionTuner {
Attrs(baseLinkAttrs).akaLink("https://twitter.com/",$0.text.replacingOccurrences(of: "@", with: ""))
}
let link = DetectionTuner {
Attrs(baseLinkAttrs).akaLink($0.text)
}
let tweet = "@all I found really nice framework to manage attributed strings. It is called Atributika. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
tweetLabel.attributedText = tweet
.style(tags: ["a": a])
.styleHashtags(hashtag)
.styleMentions(mention)
.styleLinks(link)
.attributedString
tweetLabel.onLinkTouchUpInside = { _, val in
if let linkStr = val as? String {
if let url = URL(string: linkStr) {
UIApplication.shared.openURL(url)
}
}
}
view.addSubview(tweetLabel)
```
--------------------------------
### Styling Phone Numbers
Source: https://github.com/psharanda/atributika/blob/master/README.md
Styles detected phone numbers within a string with a red foreground color. This helps in visually identifying and potentially making phone numbers interactive.
```swift
let str = "Call me (888)555-5512"
.stylePhoneNumbers(Attrs().foregroundColor(.red))
.attributedString
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.