アプリに背景画像付きの UIButton があります。
もっと長くしたいので、コードに次を追加しました。
UIImage *backgroundButton = [UIImage imageNamed:@"Button.png"];
[backgroundButton resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
[backgroundButton imageWithAlignmentRectInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
[self.loginButton setBackgroundImage:[backgroundButton imageWithAlignmentRectInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
これを避けるために、ある種のマージンを入れようとしました
このサイズで最初のボタンと同じ結果を得るにはどうすればよいですか? よろしくお願いします。
**編集*****
開発者向けに提供されている両方のメソッドを配置します
イエス:
[self.loginButton setBackgroundImage:[[UIImage imageNamed:@"Button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 8, 10, 8)] forState:UIControlStateNormal];
ゲームコン:
UIImage *modifiedBackgroundButton = [backgroundButton resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
[self.loginButton setBackgroundImage:[modifiedBackgroundButton imageWithAlignmentRectInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
[backgroundButton resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
[backgroundButton imageWithAlignmentRectInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
私は両方の答えが好きです。
結果: