Programming/Swift
[Swift] UILabel 에 글자별로 크기,색깔 변경
평생초보
2019. 2. 12. 09:01
반응형
let taskText = "All Tasks (task)"
let attributed = NSMutableAttributedString(string: taskText)
let strokeTextAttributes = [
// NSAttributedString.Key.strokeColor : UIColor.black,
NSAttributedString.Key.foregroundColor : UIColor.black,
// NSAttributedString.Key.strokeWidth : 2.0,
NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 18)
] as [NSAttributedString.Key : Any]
attributed.addAttributes(strokeTextAttributes, range: (taskText as NSString).range(of: "(task)"))
titleLabel.attributedText = attributed
반응형