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;
関連記事
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
-
-
SNS連携
Twitter・Facebookとの連携は #import <Social …
-
-
UILabelをコードで生成(Tips付)
Main Storyboard (IB)に用意されている Label を使わずに …
-
-
ボタンに画像(背景)を指定する
// ボタンのサイズを指定する UIButton *startBtn = [[U …
-
-
UIImageViewにボタンを貼りたい場合
タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …
-
-
Xcode6 GameCenter 実装
Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …
-
-
アプリの名前をつける
iPhoneのホーム画面に表示される「アプリ名」の付け方 アプリ名の変更には上 …
-
-
【Xcode ObjC #800】Documentsフォルダを見る
iPhone(iPad)のアプリに格納されているDocumentsフォルダを、i …
-
-
保護中: [Objective-C] AES/CBC/PKCS7Padding で暗号化,復号化
この投稿はパスワードで保護されているため抜粋文はありません。
-
-
CheatSheet
Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …
