ios-UIAlertView左对齐

    if ([BKCommon isNotLessThanRequireVersion:@"8.0"]) {
        // 如果ios版本大于8.0 使用UIAlertController
        if (self.isTextAlignmentLeft) {
            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];
            NSLog(@"%@",subView5.subviews);  
// 之前subView5.subviews[0]是title, subView5.subviews[1]是message
//
xcode10后发现 subView5.subviews[1]成了title,[subView5.subviews[1]是message
            //取title和message:
            if ([subView5.subviews[1] isKindOfClass:[UILabel class]]) {
                 UILabel *title = subView5.subviews[1];
            }
            if (subView5.subviews[2] isKindOfClass:[UILabel class]) {
                UILabel *message = subView5.subviews[2];
                message.textAlignment = NSTextAlignmentLeft;
            }
            
        }
Simulator Screen Shot - iPhone 8 - 2018-10-29 at 11.11.38.png

你可能感兴趣的:(ios-UIAlertView左对齐)