UIAlertController message 居左 中 右
2017-10-21 本文已影响0人
BeeQiang
写一个递归找到 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;
}