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;
関連記事
-
-
【Xcode ObjC #900】画面の明るさを変更
iPhoneの明るさを変更するメソッド ユーザーの設定している明るさの環境を勝 …
-
-
テキストの文字間を詰める
UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …
-
-
【Xcode ObjC #800】Documentsフォルダを見る
iPhone(iPad)のアプリに格納されているDocumentsフォルダを、i …
-
-
UIViewを透明にする
// opaque属性にNOを設定する事で、背景透過を許可する。 UIView …
-
-
SNS連携
Twitter・Facebookとの連携は #import <Social …
-
-
.selected
インスタンス名.selected で BOOLを宣言せずにボタンのON/OFF状 …
-
-
ステータスバーを隠す方法
Deployment Info の Status Bar Style 下部にある …
-
-
乱数のこと
乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …
-
-
経過時間を算出する
まず比較する為の時刻を予めローカルに保存するために NSUserDefaults …
-
-
LaunchImage 関連の設定
▼アプリ起動時のスプラッシュ画面 通常はチラっと一瞬だけ表示されるスプラッシュ画 …
