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;
関連記事
-
-
BGM・SE 導入方法
音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
SubViewの重ね順を変更する
SubViewの重ね順を最前面に移動する場合 bringSubviewToFro …
-
-
iPhone画面サイズ
3.5inch 320 x 480px (Retina 640 x 960px) …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
-
-
【Xcode ObjC #900】画面の明るさを変更
iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …
-
-
【Xcode ObjC】レビューアラート:SKStoreReviewController
ヘッダーでStoreKitをimport 以下を表示したいタイミングの箇所へ & …
-
-
UIBezierPath
UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …
-
-
UIImageViewにボタンを貼りたい場合
タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …
-
-
CheatSheet
Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …
