IOS developer notes (original) (raw)
UIAllert with custom buttons and background.
At firtst we create UIImage with image file of background, then set's size of allert frame, and then sets it.
UIImage *theImage = [[UIImage imageNamed:@"allert_background.png"]autorelease];
CGSize theSize = [alert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[alert layer] setContents:[theImage CGImage]];
Custom "OK" and "Custom" buttons
UIImageView *img = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bt_ok_update_base.png"]]autorelease];
UIImageView *img1 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bt_ok.png"]]autorelease];
[[alert.subviews objectAtIndex:1] addSubview:img1];
[[alert.subviews objectAtIndex:2] addSubview:img];