Replacement for UIView's contentStretch?

流过昼夜 提交于 2019-11-30 14:52:21

Use resizableImageWithCapInsets and UIEdgeInsets to make a stretching UIButton background image. For example:

UIImage* image = [UIImage imageNamed:@"image.png"];
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 20)];
[button setBackgroundImage:image forState:UIControlStateHighlighted];

I don't think you can stretch more than one pixel both horizontal and vertical.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!