美文网首页ios开发的那些坑
ios-UIAlertView左对齐

ios-UIAlertView左对齐

作者: fly大梦想家 | 来源:发表于2018-10-29 11:12 被阅读3次
        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左对齐

        本文链接:https://www.haomeiwen.com/subject/xlfbtqtx.html