代码:
//箭头
UIButton *arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
arrowBtn.frame = CGRectMake(kScreeenWidth * i + (kScreeenWidth - 60 - 10), (kCellHeight - 40) / 2., 60,40);
[arrowBtn setImage:[UIImage imageNamed:@"arrow_right_black.png"] forState:UIControlStateNormal];
// [arrowBtn setBackgroundImage:[UIImage imageNamed:@"arrow_right_black.png"] forState:UIControlStateNormal];
[arrowBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[arrowBtn setTitle:@"arrow" forState:UIControlStateNormal];
// arrowBtn.backgroundColor = [UIColor redColor];
[arrowBtn addTarget:self action:@selector(changeActivity) forControlEvents:UIControlEventTouchUpInside];
[_sectionScrollView addSubview:arrowBtn];
- setImage图片大小不会随着按钮fram改变,不会拉伸。
2.setBackgroundImage图片大小会随着按钮fram改变,跟按钮frame大小可能会拉伸变形。设置的title可以显示