我想設置圖像沒有任何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