Help us understand the problem. What is going on with this article?

resizableImageWithCapInsetsで画像を引き伸ばす

More than 5 years have passed since last update.

だいぶ前に書いた奴。
過去の投稿で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してくれる、
誰かがそんなプログラム書いてくれると信じてる(無責任

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away