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;
関連記事
-
-
UILabelをコードで生成(Tips付)
Main Storyboard (IB)に用意されている Label を使わずに …
-
-
【Xcode ObjC】レビューアラート:SKStoreReviewController
ヘッダーでStoreKitをimport 以下を表示したいタイミングの箇所へ & …
-
-
【Xcode ObjC #800】Documentsフォルダを見る
iPhone(iPad)のアプリに格納されているDocumentsフォルダを、i …
-
-
【Xcode ObjC #900】画面の明るさを変更
iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …
-
-
テキストの文字間を詰める
UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …
-
-
BGM・SE 導入方法
音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …
-
-
ボタンに画像(背景)を指定する
// ボタンのサイズを指定する UIButton *startBtn = [[U …
-
-
乱数のこと
乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …
-
-
保護中: [Objective-C] AES/CBC/PKCS7Padding で暗号化,復号化
この投稿はパスワードで保護されているため抜粋文はありません。
-
-
SubViewの重ね順を変更する
SubViewの重ね順を最前面に移動する場合 bringSubviewToFro …
