Answer the question
In order to leave comments, you need to log in
How to position text in textView to the right using NSMutableAttributedString?
How to position text in textView to the right?
I am using NSMutableAttributedString.
Attributes I set like this:
let attrs = [
NSForegroundColorAttributeName : UIColor.init(hexString: "#FF9500"),
NSTextAlignment: NSTextAlignment.right
] as [String : Any]
viewString.append(
NSMutableAttributedString(
string: symbol,
attributes: attrs1
)
)
Answer the question
In order to leave comments, you need to log in
let string = "Any String"
let style = NSMutableParagraphStyle()
style.alignment = .right
let attributes = [
NSForegroundColorAttributeName: UIColor.white,
NSParagraphStyleAttributeName: style
]
let attributedString = NSMutableAttributedString(string: string, attributes: attributes)
textView.attributedText = attributedString
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question