Кастомизация UIAlertview не отображается в iphone? - PullRequest
0 голосов
/ 16 марта 2012

У меня есть приложение в iphone, где я настраиваю свое предупреждение, используя приведенный ниже код. Он работает нормально в симуляторе. Но когда я добавил его на свой iphone, он показывает тот же синий. Не мой настроенный вид. Может кто-нибудь помочь мне, пожалуйста?

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];

1 Ответ

0 голосов
/ 16 марта 2012

Вот старая беседа на ту же тему, которая может вам помочь. Могу ли я настроить UIAlertView [iPhone iOs 4]?

Я рекомендую вам не настраивать его, поскольку в выпуске будущих версий могут возникнуть проблемы с совместимостью.Если вам настоятельно необходимо использовать другой AlertView, создайте новый, если нет, то почему бы не использовать собственный, который прекрасно работает.В случае, если это не работает правильно, не беспокойтесь, что они будут в следующем выпуске.

...