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;
関連記事
-
-
Xcode6 GameCenter 実装
Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …
-
-
UILabelをコードで生成(Tips付)
Main Storyboard (IB)に用意されている Label を使わずに …
-
-
画面ローテーション
画面ローテーションを制御する場合は下記を追加する – (BOOL)s …
-
-
【Xcode ObjC #900】画面の明るさを変更
iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …
-
-
ステータスバーを隠す方法
Deployment Info の Status Bar Style 下部にある …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
配列にNSNumberをぶちこむ
配列から数値を直に取り出したい場合はどうするのかと調べてみたのでメモ。 NSNu …
-
-
CGAffineTransformIdentity
アフィン変換がされたビューを,初期状態(アフィン変換がされていない状態)に戻す …
-
-
transform中の座標取得
CGAffineTransformを使用して画像を変化させている最中の座標取得方 …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
