写一个递归找到 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;
}
是不是很简单粗暴,欢迎点赞
网友评论