我是如何实现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];
首先声明 ,其实并不是修改背景色,而是在背景上加了个颜色图片,嘿嘿
修改后的效果
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];
相关文章推荐
- 如何修改android studio背景色(包括project view的背景色)保护眼睛人人有责
- 如何修改UITableView中SectionTitle的背景色
- 如何修改TextView链接点击实现(包含链接生成与点击原理分析)
- Android如何不用setCustomView而实现ActionBar的自定义修改
- Android 如何实现带滚动条的TextView,在更新文字时自动滚动到最后一行?
- IOS自定义UIAlertView样式,实现可替换背景和按钮
- 设备中如何实现类似gopro给iphone分配ip但是不修改dns的功能
- android:如何在TextView实现图文混排
- Android中如何使用ViewPager实现类似laucher左右拖动效果
- TextView 如何实现复制
- Revit如何修改三维视图背景色
- QTableView中的文本如何修改对齐方式
- UIAlertView的动画效果实现代码
- android TextView 如何实现消息滚动
- Android 如何实现RecyclerView横向滑动
- 修改view类的背景色
- 如何修改NSNotificationCenter addObsever方法的实现
- Java 如何实现在线预览文档及修改(Office文件)
- Android使用selector修改TextView中字体颜色和背景色的方法
- iOS View如何实现背景黑透