Method One:
NSArray*viewArray=[[[[[[[[[[[[alertController view]subviews]firstObject]subviews]firstObject]subviews]firstObject]subviews]firstObject]subviews]firstObject]subviews];UILabel*alertTitle=viewArray[0]UILabel*alertMessage=viewArray[1];alertMessage.textAlignment=NSTextAlignmentLeft;
Method Two:
#import"UIAlertController+CustomAlertController.h"
@implementationUIAlertController (CustomAlertController)
@dynamictitleLabel;
@dynamicmessageLabel;
- (NSArray*)viewArray:(UIView*)root {
NSLog(@"%@", root.subviews);
staticNSArray*_subviews =nil;
_subviews =nil;
for(UIView*vinroot.subviews) {
if(_subviews) {
break;
}
if([visKindOfClass:[UILabelclass]]) {
_subviews = root.subviews;
return_subviews;
}
[selfviewArray:v];
}
return_subviews;
}
- (UILabel*)titleLabel {
return[selfviewArray:self.view][0];
}
- (UILabel*)messageLabel {
return[selfviewArray:self.view][1];
}
@end