gpt4 book ai didi

iphone ==> UIAlertView 改变背景?

转载 作者:行者123 更新时间:2023-12-03 20:35:47 25 4
gpt4 key购买 nike

我正在尝试更改 uialertview 的背景。一切工作正常,除了我添加到 uialert View 的背景图像不会在警报 View 内缩放。所以基本上你只能看到基于当前大小的背景图像的一部分。有什么方法可以使图像在警报 View 内缩放直到适合吗?

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

最佳答案

请看一下: http://joris.kluivers.nl/iphone-dev/?p=CustomAlert

他们解释了如何通过子类化 UIAlertView 来做到这一点。祝你好运!

关于iphone ==> UIAlertView 改变背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3410782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com