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

  関連記事

no image
NSLog まとめ

デバッグする時などに、ログを出力する方法としてNSLogを使用します。 文字列を …

no image
画面ローテーション

画面ローテーションを制御する場合は下記を追加する – (BOOL)s …

eyechatch_xcode_tips-300x300
配列にNSNumberをぶちこむ

配列から数値を直に取り出したい場合はどうするのかと調べてみたのでメモ。 NSNu …

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

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

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
UIImageViewにボタンを貼りたい場合

タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …

eyechatch_xcode_tips-300x300
経過時間を算出する

まず比較する為の時刻を予めローカルに保存するために NSUserDefaults …

no image
CGAffineTransformIdentity

アフィン変換がされたビューを,初期状態(アフィン変換がされていない状態)に戻す …

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

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

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

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