Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //建立UIAlertController
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
- [alert addAction:defaultAction];
- //Message排版
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- paragraphStyle.alignment = NSTextAlignmentCenter;
- //Message1 置中
- NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"Message1" attributes:@{NSParagraphStyleAttributeName:paragraphStyle}];
- NSMutableParagraphStyle *mParagraphStyle = [[NSMutableParagraphStyle alloc] init];
- mParagraphStyle.alignment = NSTextAlignmentLeft;
- //Message2 靠左
- NSMutableAttributedString *message = [[NSMutableAttributedString alloc] initWithString:@"\nMessage2-1\nMessage2-2\nMessage2-3\nMessage2-4" attributes:@{NSParagraphStyleAttributeName:mParagraphStyle}];
- [attributedStr appendAttributedString:message];
- [alert setValue:attributedStr forKey:@"attributedMessage"];
- [self presentViewController:alert animated:YES completion:nil];
Add Comment
Please, Sign In to add comment