Question : how to bold 1 word swift
Answered by : powerful-peacock-35i6vyx79g2c
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
Source : https://stackoverflow.com/questions/36486761/make-part-of-a-uilabel-bold-in-swift | Last Update : Sun, 28 Jun 20
Question : bold world in text swift
Answered by : alice-roncella
Text("Bold text").bold() + Text("normal text")
Source : | Last Update : Sun, 18 Apr 21