iOS Uialertview rarely have a separate customization needs, generally using system style, but sometimes some special requirements (such as: Uialertview font, font size, font alignment changes, etc.) will have to need to customize the Uialertview alone.
The custom method is also very simple, in Viewcontroller delegate implementation method Willpresentalertview traverse Uialertview all Subview below, Find the corresponding Uilabel and then modify the properties of the Uilabel. The operation is basically consistent.
Reference code;
The code is as follows |
Copy Code |
-(void) Willpresentalertview: (Uialertview *) Alertview { Iterate through all the controls contained in the Uialertview For (UIView *tempview in alertview.subviews) {
if ([Tempview Iskindofclass:[uilabel class]]) { When the control is a Uilabel Uilabel *templabel = (Uilabel *) Tempview;
if ([Templabel.text isEqualToString:alertView.message]) { Adjust alignment Templabel.textalignment = Uitextalignmentleft; Adjust font size [Templabel Setfont:[uifont systemfontofsize:15.0]]; } } } } |
The above code does not appear to use the private API problem