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
保護中: [Objective-C] AES/CBC/PKCS7Padding で暗号化,復号化

この投稿はパスワードで保護されているため抜粋文はありません。

no image
UIView

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

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

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

eyechatch_xcode_tips-300x300
LaunchImage 関連の設定

▼アプリ起動時のスプラッシュ画面 通常はチラっと一瞬だけ表示されるスプラッシュ画 …

no image
UIViewを透明にする

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

no image
NSLog まとめ

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

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
NSArray valueForkeypath関数

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

eyechatch_xcode_tips-300x300
.selected

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

eyechatch_xcode_tips-300x300
よく使うショートカット

Ctrl+6 : 表示中のクラスのメソッド一覧 さらにテキスト入力してインクリメ …