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
経過時間を算出する

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

eyechatch_xcode_tips-300x300
テキストの文字間を詰める

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

no image
UIViewを透明にする

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

no image
UIView

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

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

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

no image
UIImageView 画像の差し替え

[UIImageView alloc] 後の画像を変換する時は下記コードを参照し …

no image
NSArray valueForkeypath関数

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

no image
アプリの名前をつける

iPhoneのホーム画面に表示される「アプリ名」の付け方 アプリ名の変更には上 …

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

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

eyechatch_xcode_tips-300x300
UIBezierPath

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