原有的问题如下
Xnip2022-01-06_10-29-40.jpg解决之后
Xnip2022-01-06_10-29-55.jpg
解决方案如下
self.loginButton.layer.cornerRadius = 5;
self.loginButton.clipsToBounds = YES;
//让背景图片不要拉伸
UIImage *image = _loginButton.currentBackgroundImage;
image = [image stretchableImageWithLeftCapWidth:image.size.width / 2 topCapHeight:image.size.height / 2];
[_loginButton setBackgroundImage:image forState:UIControlStateNormal];
[self.loginButton setBackgroundImage:image forState:UIControlStateHighlighted];
放在viewDidLoad调用
网友评论