【发布时间】:2017-06-06 07:01:26
【问题描述】:
我正在尝试在没有任何 uiimageview 的情况下设置图像,现在我有了图像,但它水平重复了两次我想缩放并将其修复为屏幕大小你怎么做??
我尝试了一些方法,但没有成功
下面是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"background_themee.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// self.view.backgroundColor = [UIColor colorWithPatternImage:image];
// UIGraphicsBeginImageContext(self.view.frame.size);
// [[UIImage imageNamed:@"background_themee.png"] drawInRect:self.view.bounds];
// UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
// UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_themee"]];
// Do any additional setup after loading the view.
}
提前感谢您的建议!!
【问题讨论】:
-
简单这一行就够了
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_themee"]]; -
@GeneCode 好的,让我试试吧!
标签: ios objective-c xcode background