使用图案设置背景颜色图像在iOS7上显示黑色/透明屏幕

时间:2015-01-30 23:23:24

标签: ios uiimage

我正在尝试为我的应用设置背景图片。我在ViewDidLoad中使用此代码:

UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"TablePlate"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

self.view.backgroundColor = [UIColor colorWithPatternImage:image];

在iOS8下执行时效果很好(出于某种原因)。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

只需使用此代码而不是使用图形上下文:

- (void)viewDidLoad{
     [super viewDidLoad];

     self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TablePlate"]];

}