美文网首页
UIAlertController message 居左 中 右

UIAlertController message 居左 中 右

作者: BeeQiang | 来源:发表于2017-10-21 14:57 被阅读0次

    写一个递归找到 UIAlertController 的 message

    UIView *messageParentView = [self getParentViewOfTitleAndMessageFromView:AlertController.view];
        if (messageParentView && messageParentView.subviews.count > 1) {
            UILabel *messageLb = messageParentView.subviews[1];
            messageLb.textAlignment  = NSTextAlignmentLeft;
        }
    
    - (UIView *)getParentViewOfTitleAndMessageFromView:(UIView *)view {
        for (UIView *subView in view.subviews) {
            if ([subView isKindOfClass:[UILabel class]]) {
                return view;
            }else{
                UIView *resultV = [self getParentViewOfTitleAndMessageFromView:subView];
                if (resultV) return resultV;
            }
        }
        return nil;
    }
    
    

    是不是很简单粗暴,欢迎点赞

    相关文章

      网友评论

          本文标题:UIAlertController message 居左 中 右

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