您的位置:首页 > 产品设计 > UI/UE

我是如何实现UIalertView背景色的修改的

2013-01-26 23:14 246 查看
转载自:http://www.cocoachina.com/bbs/read.php?tid-11741-toread-1.html

首先声明  ,其实并不是修改背景色,而是在背景上加了个颜色图片,嘿嘿

修改后的效果

2011-11-24更新:

随着sdk的不断更新,这个办法现在已经实效了。
谢谢65楼给出的解决办法,测试了一下,这个办法也只在模拟器上起作用

修改了一下,下面的代码能达到原来的效果
    UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"
                                                        message: @"I'm a Chinese!"
                                                       delegate:nil 
                                              cancelButtonTitle:@"Cancel" 
                                              otherButtonTitles:@"Okay",nil] autorelease];
    
    [theAlert show];

    UIView *additonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, alert.frame.size.width-30, alert.frame.size.height-20)];
    additonBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"loveChina.png"]];
#if TARGET_IPHONE_SIMULATOR
    [theAlert insertSubview:additonBackgroundView atIndex:1];
#else
    [theAlert insertSubview:additonBackgroundView atIndex:0];
#endif
        [additonBackgroundView release];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: