Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- GCD
- push
- swift
- 스마트폰
- 포켓볼
- Check
- 신도림 테크노마트
- simulator
- 페이백
- 포켓몬 GO
- Xcode
- Example
- 아이폰7
- 신도림
- loop
- UITableView
- swift3
- LG유플러스
- 공략
- 샘플
- 얻는법
- 해몽
- setting
- UIView
- afterdelay
- error
- 앱스토어
- Bitcode
- 보라카이
- IOS
Archives
- Today
- Total
도래울
swift uilabel multi color, font 본문
First of all initialize of you NSString and NSMutableAttributedString as below.
var myString:NSString = "I AM KIRIT MODI"
var myMutableString = NSMutableAttributedString()
In ViewDidLoad
override func viewDidLoad() {
myMutableString = NSMutableAttributedString(string: myString, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 18.0)!])
myMutableString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSRange(location:2,length:4))
// set label Attribute
labName.attributedText = myMutableString
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
You OUTPUT :
MULTIPLE COLOR
Add in you ViewDidLoad below line code to get multiple color in string.
myMutableString.addAttribute(NSForegroundColorAttributeName, value: UIColor.greenColor(), range: NSRange(location:10,length:5))
Mupltiple color OUTPUT
'개발 > iOS' 카테고리의 다른 글
swift uitableview cell insert delete crash (0) | 2016.06.07 |
---|---|
swift for문 index알기 (0) | 2016.05.26 |
swift alert ios8 example (0) | 2016.05.23 |
UITextField 에서 Money Format 자동완성 하기 (0) | 2016.05.23 |
Swift image viewer 오픈소스 (0) | 2016.05.10 |
Comments