You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Decorator with specific Style and link it at the end of needed string or wrap for styling:
"Style"+ d1 +"Decorator"+ d2 +"!"
// or
d1.wrap("Style")+ d2.wrap("Decorator")+"!"
Example:
leta=Decorator(style:Style().foregroundColor(.black).kerning(-0.5).backgroundColor(.darkGray))letb=Decorator(style:Style().foregroundColor(.white).backgroundColor(.black))letc=Decorator(style:Style().foregroundColor(.gray).alignment(.right))
// You can write in syntax you prefer
letdecoratedText="Bold"+ a +"Heavy"+ b +"Black"+ c
label.attributedText =NSAttributedString(decorator: decoratedText)
// or
leta1= a.wrap,b1= b.wrap,c1= c.wrap
letdecoratedText2=a1("Bold")+ b1("Heavy")+ c1("Black")
label.attributedText =NSAttributedString(decorator: decoratedText2)
String can be designed dynamically:
// check Example for detailed code, where created 'd', 'e', 'f' etc
lettitleText="! "+("Bold"+ b +"Heavy"+ c +"Black"+ d)letdecoratedText="Decorate attributed string simply"+ a +"\n\n"+ titleText +"\n\n"+"Right"+ e +"\n"+"below black rect with red line"+ f +"\n\n\nwith default attributes"letdefaultAttributes=Style().font(UIFont.systemFont(ofSize:15, weight: UIFontWeightBlack)).alignment(.center).attributes
label.attributedText =NSAttributedString(decorator: decoratedText, attributes: defaultAttributes)