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;
関連記事
-
-
経過時間を算出する
まず比較する為の時刻を予めローカルに保存するために NSUserDefaults …
-
-
テキストの文字間を詰める
UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …
-
-
UIViewを透明にする
// opaque属性にNOを設定する事で、背景透過を許可する。 UIView …
-
-
UIView
タイトル画面の背景など、新たにビューを追加した場合 UIViewを生成し sel …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
UIImageView 画像の差し替え
[UIImageView alloc] 後の画像を変換する時は下記コードを参照し …
-
-
NSArray valueForkeypath関数
NSArrayやNSDictionaryを多用する人にお勧めですCoreData …
-
-
アプリの名前をつける
iPhoneのホーム画面に表示される「アプリ名」の付け方 アプリ名の変更には上 …
-
-
UILabelをコードで生成(Tips付)
Main Storyboard (IB)に用意されている Label を使わずに …
-
-
UIBezierPath
UIImageでpngやjpgを指定する方法は、書籍やブログなどで情報を手に入れ …