Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone==>;你想改变背景吗?_Iphone_Background Image_Uialertview - Fatal编程技术网

iphone==>;你想改变背景吗?

iphone==>;你想改变背景吗?,iphone,background-image,uialertview,Iphone,Background Image,Uialertview,我正在尝试更改uialertview的背景。 除了我添加到uialert视图中的背景图像不会在alertview中缩放外,其他一切都正常。因此,基本上,根据当前大小,您只能看到我背景图像的一部分。 有没有办法使图像在alerview中缩放到合适的位置 UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:title messag

我正在尝试更改uialertview的背景。 除了我添加到uialert视图中的背景图像不会在alertview中缩放外,其他一切都正常。因此,基本上,根据当前大小,您只能看到我背景图像的一部分。 有没有办法使图像在alerview中缩放到合适的位置

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=…