Search This Blog

Friday, 24 August 2012

How to change the UIAlertView FontColors and FontStyles in xcode

Hello Friends,
                     As in morning today i was trying to do something that is changing the looks of AlertView that my app displays , but as far as i worked with xcode4.2 their is no way i found to change the default blue color of the standard AlertView or may be i did something wrong ..... ;P but somehow i worked and successfully changed the font styles and colors of text shown in AlertView ,here is the code .....


First of all you have to include UIAlertViewDelegate in your view's .h file like below:



Noe over ride the below function in your view's .m file

-(void)willPresentAlertView:(UIAlertView *)a;ertView{
UILabel *title = [alertView valurForKey:@"_titleLabel"];
title.font = [UIFont fontWithName:@"Arial" size:18];
[title setTextColor:[UIColor whiteColor];

UILabel *body = [alertView valueForKey:@"_bodyTextLabel"];
body.font = [UIFont fontWithName:@"Arial" size:15];
[body setTextColor:[UIColor whiteColor];

That it , whenever your this view present a AlertView this function will be executed.....try different font styles and size....but remember there is no way to change the background as far as i worked on it i succeed in displaying a image but that was below that blue no Luck!


  1. is there any way to set the font for cancel button and other buttons title in alertView

  2. Hello sumi ,
    Nice question but i have something better for you , if you really want to use a custom alert view,Better use a UIView with everything customised, and set it to hidden , where you are displaying a Alert view set that UIView to setHidden:NO ,if you do little R&D you will be able to use nice animation too with this View , ask me if you will need a animation code.
    Happy Programming ;)

  3. Tested in iOS7 and it doesn't work any more, any better idea? Thanks

    1. iOS 7 don't allow developer customize UIAlertView

  4. why don't allow ios 7 ? please elaborated answer .