1. 程式人生 > >iOS UIAlertController 文字左對齊

iOS UIAlertController 文字左對齊

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action1 = [UIAlertActionactionWithTitle:@"好的"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction * _Nonnull action) {

    }];

    [alertController addAction

:action1];

    UIView *subView1 = alertController.view.subviews[0];

    UIView *subView2 = subView1.subviews[0];

    UIView *subView3 = subView2.subviews[0];

    UIView *subView4 = subView3.subviews[0];

    UIView *subView5 = subView4.subviews[0];

    UILabel *title = subView5.subviews[0];

    UILabel *message = subView5.subviews

[1];

    message.textAlignment = NSTextAlignmentLeft;

UIViewController *rootVC = [[UIApplicationsharedApplication]delegate].window.rootViewController;

    [rootVC presentViewController:alertController animated:YEScompletion:nil];