代碼:
//箭頭
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圖片大小不會(huì)隨著按鈕fram改變,不會(huì)拉伸。
2.setBackgroundImage圖片大小會(huì)隨著按鈕fram改變,跟按鈕frame大小可能會(huì)拉伸變形。設(shè)置的title可以顯示