UIViewの背景画像をフィットさせたい
UIViewは(UIImageViewとは違い)背景画像のサイズをフィットする機能がないので、image自体をビューのサイズに合わせて再描画する必要がある。
NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; UIImage *image; image = [UIImage imageWithContentsOfFile:[bundlePath stringByAppendingPathComponent:@"img/common/Title_Image_Bg.png"]]; UIGraphicsBeginImageContext(self.frame.size); [image drawInRect:self.bounds]; UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self setBackgroundColor:[UIColor colorWithPatternImage:backgroundImage]]; image = nil; backgroundImage = nil;
関連記事
-
-
.selected
インスタンス名.selected で BOOLを宣言せずにボタンのON/OFF状 …
-
-
UIImageViewにボタンを貼りたい場合
タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …
-
-
UIBezierPath
UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …
-
-
LaunchImage 関連の設定
▼アプリ起動時のスプラッシュ画面 通常はチラっと一瞬だけ表示されるスプラッシュ画 …
-
-
ステータスバーを隠す方法
Deployment Info の Status Bar Style 下部にある …
-
-
iPhone画面サイズ
3.5inch 320 x 480px (Retina 640 x 960px) …
-
-
SubViewの重ね順を変更する
SubViewの重ね順を最前面に移動する場合 bringSubviewToFro …
-
-
画面ローテーション
画面ローテーションを制御する場合は下記を追加する – (BOOL)s …
-
-
【Xcode ObjC #800】Documentsフォルダを見る
iPhone(iPad)のアプリに格納されているDocumentsフォルダを、i …
-
-
transform中の座標取得
CGAffineTransformを使用して画像を変化させている最中の座標取得方 …
