繁体   English   中英

在iOS7上将PatternColor设置为BackgroundColor会导致黑色/透明屏幕

[英]Set BackgroundColor with Pattern Image results in black/transparent screen on iOS7

我正在尝试为我的应用设置背景图片。 我在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"]];

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM