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;
関連記事
-
-
UIBezierPath
UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …
-
-
for文の便利な使い方
for文を使って繰り返し実行させる場合、基本的には数値を使ってループさせます。 …
-
-
【Xcode ObjC】レビューアラート:SKStoreReviewController
ヘッダーでStoreKitをimport 以下を表示したいタイミングの箇所へ & …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
テキストの文字間を詰める
UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …
-
-
BGM・SE 導入方法
音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …
-
-
ボタンに画像(背景)を指定する
// ボタンのサイズを指定する UIButton *startBtn = [[U …
-
-
SNS連携
Twitter・Facebookとの連携は #import <Social …
-
-
CheatSheet
Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
