how to bold 1 word swift
extension String {
func withBoldText(text: String, font: UIFont? = nil) -> NSAttributedString {
let _font = font ?? UIFont.systemFont(ofSize: 14, weight: .regular)
let fullString = NSMutableAttributedString(string: self, attributes: [NSAttributedString.Key.font: _font])
let boldFontAttribute: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: _font.pointSize)]
let range = (self as NSString).range(of: text)
fullString.addAttributes(boldFontAttribute, range: range)
return fullString
}}
// USE CASE:
let text = "Discover New Shops.".withBoldText(text: "New")
label.attributedText = headerTitle
Also in Swift:
- how to swift pie chart quartzcore framework
- swift session.input
- pop the view controller xcode
- string.format swift
- create protocol swift
- how to change the font of buttons programmatically swift
- swift double v float
- Decimal to Double conversion in Swift
- swift edit constraint programmatically
- swift animate a label ishidden
- play sound swift stack overflow
- swift find difference between two arrays
- uilabel center text programmatically swift
- swift update uilabel text button
- detect binding valu change swiftui
- swift play video from url
- view will appear
- remove cocoapods swiftr
- swift create array from range
- xcode disable a button
- add textfield in swiftui
- conert data to string swift
- xcode label rotate text
- get local currency iap swift