我正在尝试为我的应用设置背景图片。我在我的 ViewDidLoad 中使用这段代码:
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"TablePlate"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
在 iOS8 下执行时它工作正常(出于某种原因)。
有什么想法吗?
最佳答案
只需使用此代码而不是使用图形上下文:
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TablePlate"]];
}
关于ios - 在 iOS 7 上使用图案图像设置背景颜色会导致黑色/透明屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28246274/