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;
関連記事
-
-
【Xcode ObjC】レビューアラート:SKStoreReviewController
ヘッダーでStoreKitをimport 以下を表示したいタイミングの箇所へ & …
-
-
iPhone画面サイズ
3.5inch 320 x 480px (Retina 640 x 960px) …
-
-
UILabelをコードで生成(Tips付)
Main Storyboard (IB)に用意されている Label を使わずに …
-
-
BGM・SE 導入方法
音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
-
-
乱数のこと
乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
UIView
タイトル画面の背景など、新たにビューを追加した場合 UIViewを生成し sel …
-
-
UIBezierPath
UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …
-
-
NSArray valueForkeypath関数
NSArrayやNSDictionaryを多用する人にお勧めですCoreData …
