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
【Xcode ObjC】レビューアラート:SKStoreReviewController

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

no image
iPhone画面サイズ

3.5inch 320 x 480px (Retina 640 x 960px) …

no image
UILabelをコードで生成(Tips付)

Main Storyboard (IB)に用意されている Label を使わずに …

no image
BGM・SE 導入方法

音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
乱数のこと

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

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

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

no image
UIView

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

eyechatch_xcode_tips-300x300
UIBezierPath

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

no image
NSArray valueForkeypath関数

NSArrayやNSDictionaryを多用する人にお勧めですCoreData …