讓圖片只拉伸最中心的那一像素
#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