IOS solves the problem of button background picture stretching (recommended)

Time:2021-10-10

The problem is shown in the figure below:

这里写图片描述

The background picture of the setting button is stretched

Solution

- (void)awakeFromNib
{
  [super awakeFromNib];
  //Let the background picture not stretch
  UIImage *image = _loginRegisterBtn.currentBackgroundImage;
  image = [image stretchableImageWithLeftCapWidth:image.size.width / 2 topCapHeight:image.size.height / 2];
  [_loginRegisterBtn setBackgroundImage:image forState:UIControlStateNormal];
}

Effect after setting:

这里写图片描述

summary

The above is what Xiaobian introduced to you about IOS to solve the problem of stretching the button background picture (recommended). I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support to the developeppaer website!

Recommended Today

SQL exercise 20 – Modeling & Reporting

This blog is used to review and sort out the common topic modeling architecture, analysis oriented architecture and integration topic reports in data warehouse. I have uploaded these reports to GitHub. If you are interested, you can have a lookAddress:https://github.com/nino-laiqiu/TiTanI recorded a relatively complete development process in my hexo blog deployed on GitHub. You can […]