让图片只拉伸最中心的那一像素
#import "MMMyLotteryViewController.h"
@interface MMMyLotteryViewController ()
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@end
@implementation MMMyLotteryViewController
- (void)viewDidLoad {
[super viewDidLoad];
//解决自动布局下图片拉伸导致边缘模糊的问题
UIImage *bacImage = self.loginBtn.currentBackgroundImage;
//让图片只拉伸最中心的那一像素,得到新图片
bacImage = [bacImage stretchableImageWithLeftCapWidth:bacImage.size.width*0.5 topCapHeight:bacImage.size.height*0.5];
//将新图片设置回去
[self.loginBtn setBackgroundImage:bacImage forState:UIControlStateNormal];
}
@end