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;
関連記事
-
-
Xcode6 GameCenter 実装
Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …
-
-
UIImageView 画像の差し替え
[UIImageView alloc] 後の画像を変換する時は下記コードを参照し …
-
-
NSLog まとめ
デバッグする時などに、ログを出力する方法としてNSLogを使用します。 文字列を …
-
-
【Xcode ObjC #900】画面の明るさを変更
iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …
-
-
ステータスバーを隠す方法
Deployment Info の Status Bar Style 下部にある …
-
-
乱数のこと
乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
-
-
UIViewを透明にする
// opaque属性にNOを設定する事で、背景透過を許可する。 UIView …
-
-
ボタンに画像(背景)を指定する
// ボタンのサイズを指定する UIButton *startBtn = [[U …
