iphone==>;你想改变背景吗?
我正在尝试更改uialertview的背景。 除了我添加到uialert视图中的背景图像不会在alertview中缩放外,其他一切都正常。因此,基本上,根据当前大小,您只能看到我背景图像的一部分。 有没有办法使图像在alerview中缩放到合适的位置iphone==>;你想改变背景吗?,iphone,background-image,uialertview,Iphone,Background Image,Uialertview,我正在尝试更改uialertview的背景。 除了我添加到uialert视图中的背景图像不会在alertview中缩放外,其他一切都正常。因此,基本上,根据当前大小,您只能看到我背景图像的一部分。 有没有办法使图像在alerview中缩放到合适的位置 UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:title messag
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:title
message:msg
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[theAlert show];
UIImage *theImage = [UIImage imageNamed:@"bg.jpg"];
theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
CGSize theSize = [theAlert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theAlert.frame.size.width, theAlert.frame.size.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
theAlert.layer.contents = (id)[theImage CGImage];
[theAlert release];
请看:
它们通过对UIAlertView进行子类化来解释如何做到这一点。祝你好运 在iOS 6.1上运行良好,但不支持不同的界面方向(警报将仅在纵向模式下)。我说的是这个链接:如果你想实现不同的方向支持,你可以子类
UIViewController
,使用相同的window
方法,只需更改[window addSubview::
window.rootViewController=…