I have an application in iphone where i am customizing my alertview using the bellow code. It is working fine in the simulator.But when i added it to my iphone it is showing the same blue one.Not my customised view.Can anybody help me please?
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"title" message:@"canceled"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
//[alert setUIColor:[UIColor brownColor]];
/*[alert show];
[alert release];*/
//UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"Message" message:@"canceled"
//delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[theAlert show];
UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor whiteColor]];
UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor whiteColor]];
theBody.font = [UIFont boldSystemFontOfSize:16.0];
UIImage *theImage = [UIImage imageNamed:@"pop_up.png"];
theImage = [theImage stretchableImageWithLeftCapWidth:28 topCapHeight:28];
CGSize theSize = [theAlert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//[[theAlert layer] setContents:[theImage CGImage]];
[[theAlert layer] setContents:(id)[theImage CGImage]];
[theAlert release];
Here’s an old conversation for the same topic that can help you.
Can I customise the UIAlertView [iPhone iOs 4]?
I recommend you not to customize it, because in futures release you may have compatibility problems.
If you strongly need to use another AlertView create a new one, if not why not to use the native one that works great. In case, it doesn’t works correctly don’t worry sure that they will in next release.