LoginSignup
5
4

More than 5 years have passed since last update.

resizableImageWithCapInsetsで画像を引き伸ばす

Posted at

だいぶ前に書いた奴。
過去の投稿でstretchableImageWithLeftCapWidthを使った内容を書いたけど、
あのメソッドはdeprecatedになっていたので今後はこのメソッドにお世話になりそうです。

使い方はコード見たほうが早い。

サンプル
    UIImage *image = [UIImage imageNamed:@"button.png"];
    UIImage *resizeImage = [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
    [button setBackgroundImage:resizeImage forState:UIControlStateNormal];

センスないやっつけ画像ですが、一応Githubにもあげてます。
https://github.com/niyaty/ResizableImage

実際に動かすとこんな感じ。

Image

余談

画像ははてなにupしてます。
というところで前々から思ってたんだけど、
ブログにUPした画像URLをQiitaに持ってくれば両方に投稿できてお得感満載。

自動で上手くリンクついた状態でブログとQiitaにpostしてくれる、
誰かがそんなプログラム書いてくれると信じてる(無責任

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4