
UIViewには、setBackgroundImageのメソッドは無いので、
その為のメモ
UIViewにUIImageを背景設定するには、setBackgroundColorを使います。
[self.view setBackgroundColor:[UIColor colorWithPatternImage:backgroundImage]];
と、まぁ、こんな感じになるのですが、
描画範囲に最適化して背景を描画したい場合もあります。
その場合は、
UIGraphicsBeginImageContext(self.view.frame.size); [backgroundImage drawInRect:self.view.bounds]; UIImage *bgImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self.view setBackgroundColor:[UIColor colorWithPatternImage:bgImg]];
と、こんな感じに変更します。
0 件のコメント:
コメントを投稿