По умолчанию alertView в iphone поставляется с цветом фона (iPhone) - PullRequest
1 голос
/ 25 июня 2011

Я очень часто использую представление предупреждений по умолчанию в своем приложении для iPhone. Но иногда оно идет не так, как обычно, без фона (отображение только текста при просмотре). Пожалуйста, помогите мне.Спасибо и С наилучшими пожеланиями Нараяна

1 Ответ

3 голосов
/ 08 сентября 2011

попробуйте эту альтернативу

посмотрите также этот URL http://kwigbo.com/post/318396305/iphone-sdk-custom-uialertview-background-color

Background of AlertView is an image And you can change this image



UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"
   message: @"YOUR MESSAGE HERE", nil)
   delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];

    [theAlert show];

   UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
   [theTitle setTextColor:[UIColor redColor]];

   UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
   [theBody setTextColor:[UIColor blueColor]];

   UIImage *theImage = [UIImage imageNamed:@"Background.png"];    
   theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
   CGSize theSize = [theAlert frame].size;

   UIGraphicsBeginImageContext(theSize);    
   [theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];    
   theImage = UIGraphicsGetImageFromCurrentImageContext();    
   UIGraphicsEndImageContext();

   [[theAlert layer] setContents:[theImage CGImage]];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...