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
テキストの文字間を詰める

UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …

no image
UIViewを透明にする

// opaque属性にNOを設定する事で、背景透過を許可する。 UIView …

eyechatch_xcode_tips-300x300
【Xcode ObjC #800】Documentsフォルダを見る

iPhone(iPad)のアプリに格納されているDocumentsフォルダを、i …

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

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

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

no image
CGAffineTransformIdentity

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

no image
iPhone画面サイズ

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

no image
BGM・SE 導入方法

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

eyechatch_xcode_tips-300x300
.selected

インスタンス名.selected で BOOLを宣言せずにボタンのON/OFF状 …

eyechatch_xcode_tips-300x300
負の数を絶対数へ変換 abs

負の数を自然数(マイナスを含まない数字)にしたくて、「Xcode 自然数 変換」 …