Developer's log book
UIAlertController 의 본문 왼쫀정렬
upthere9
2019. 1. 29. 23:29
https://stackoverflow.com/questions/25962559/uialertcontroller-text-alignment/26949674
UIAlertController에서 message 에 해당하는 본문의 정렬 스타일을 아래의 방법으로 바꿀 수 있다.
아래 예시는 글꼴 스타일을 유지한 채로 정렬만 왼쪽으로 바꾼다.
NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
paraStyle.alignment = NSTextAlignmentLeft;
NSMutableAttributedString *atrStr =
[[[NSMutableAttributedString alloc] initWithString:avc.message attributes:@{
NSParagraphStyleAttributeName:paraStyle,
NSFontAttributeName: [UIFont preferredFontForTextStyle: UIFontTextStyleFootnote],
}]
autorelease];
[avc setValue:atrStr forKey:@"attributedMessage"];