IOS Custom system Uialertview Adjust alert font

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.