Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kean/Formatting
https://github.com/kean/Formatting
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/kean/Formatting
- Owner: kean
- License: mit
- Created: 2020-11-29T22:41:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T20:52:36.000Z (5 months ago)
- Last Synced: 2024-07-19T04:35:32.618Z (about 2 months ago)
- Language: Swift
- Size: 36.1 KB
- Stars: 177
- Watchers: 6
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Formatting
An example code for [kean.blog: Formatted Localizable Strings](https://kean.blog/post/formatted-strings). Demonstrates how to implement basic string formatting using XML tags.
```swift
let input = "M1 delivers up to 2.8x faster processing performance than the previous generation."
let text = String(format: input, "https://support.apple.com/kb/SP799")
let style = FormattedStringStyle(attributes: [
"body": [.font: UIFont.systemFont(ofSize: 15)],
"b": [.font: UIFont.boldSystemFont(ofSize: 15)],
"a": [.underlineColor: UIColor.clear]
])
label.attributedText = NSAttributedString(formatting: text, style: style)
```Result using standard `UILabel`:
![Screen Shot 2020-11-29 at 18 07 03](https://user-images.githubusercontent.com/1567433/100556269-29dc6380-326f-11eb-8afe-769d48706362.png)
## Minimum Requirements
| Versio | Swift | Xcode | Platforms |
|-----------------|-----------|-------------|----------------------------------------------|
| Formatting 4.0 | Swift 5.8 | Xcode 14.3 | iOS 12.0, tvOS 12.0, watchOS 5.0, macOS 10.5 |# License
Formatting is available under the MIT license. See the LICENSE file for more info.