我想设置图像没有任何uiimageview,现在我有图像,但它是水平重复两次我想缩放和修复它到屏幕大小你如何做到这一点??如何缩放以适合背景图像的目标c
我已经尝试了一些方法,但没有制定出
下面是我的代码:
- (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 ok让我试试吧! – Akshay