NSMutableAttributedString
2021. 5. 11. 11:26ㆍ개발자료/iOS
반응형
# 기본
NSString* strText = @"가나다라 1234 ABCD abcd";
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:strText];
# 폰트(Font) 설정
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0f];
[attString addAttribute:NSFontAttributeName
value:font
range:NSMakeRange(0, strText.length)];
# 색상(Color) 설정
UIColor *color = [UIColor redColor];
[attString addAttribute:NSForegroundColorAttributeName
value:color
range:NSMakeRange(0, strText.length)];
# 행간격 (Line Spacing)
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:15];
[attString addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:NSMakeRange(0, strText.length)];
반응형
'개발자료 > iOS' 카테고리의 다른 글
NSNotification (0) | 2021.05.31 |
---|---|
NSArray - indexOfObject, indexOfObjectIdenticalTo (0) | 2021.05.21 |
[XIB] UILabel (0) | 2021.05.10 |
특정 시간후에 코드 실행하기 (0) | 2021.04.30 |
info.plist (0) | 2021.04.08 |