Need help with Formatting?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kean
160 Stars 8 Forks 10 Commits 0 Opened issues

Services available

!
?

Need anything else?

Contributors list

# 16,513
Swift
webp
Objecti...
uistack...
9 commits

Formatting

An example code for kean.blog: Formatted Localizable Strings. Demonstrates how to implement basic string formatting using XML tags.

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

License

Formatting is available under the MIT license. See the LICENSE file for more info.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.