我正在尝试为我的应用设置背景图片。我在ViewDidLoad中使用此代码:
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"TablePlate"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
在iOS8下执行时效果很好(出于某种原因)。
有什么想法吗?
答案 0 :(得分:2)
只需使用此代码而不是使用图形上下文:
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TablePlate"]];
}