Tabs

iPhone&Androidのアプリ制作・デザイン

*

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;

 - Begin, Xcode

  関連記事

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
SubViewの重ね順を変更する

SubViewの重ね順を最前面に移動する場合 bringSubviewToFro …

no image
タッチイベント:有効・無効

// タッチイベントを有効にしたい場合の処理 [[UIApplication s …

no image
ステータスバーを隠す方法

Deployment Info の Status Bar Style 下部にある …

no image
CheatSheet

Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …

no image
UIView

タイトル画面の背景など、新たにビューを追加した場合 UIViewを生成し sel …

eyechatch_xcode_tips-300x300
【Xcode ObjC】レビューアラート:SKStoreReviewController

ヘッダーでStoreKitをimport 以下を表示したいタイミングの箇所へ & …

no image
乱数のこと

乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …

eyechatch_xcode_tips-300x300
UIBezierPath

UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …

eyechatch_xcode_tips-300x300
【Xcode ObjC #900】画面の明るさを変更

iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …