UIImage * CharacterBtnImage = [UIImage imageNamed:@"whiteBack"];
CharacterBtnImage = [CharacterBtnImage stretchableImageWithLeftCapWidth:CharacterBtnImage.size.width * 0.5 topCapHeight:CharacterBtnImage.size.height * 0.5];
UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(10, 100, 280, 50);
[btn1 setTitle:@"登陆" forState:UIControlStateNormal];
[btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self.view addSubview:btn1];
// 这里一定要用 setBackgroundImage
[btn1 setBackgroundImage:CharacterBtnImage forState:UIControlStateNormal];
如有问题可添加我的QQ:1290925041
还可添加QQ群:234812704(洲洲哥学院)
欢迎各位一块学习,提高逼格!
也可以添加洲洲哥的微信公众号