我有一个带有 1)标题 2)背景图像的按钮,但是在突出显示时它会异常调整图像。中间有白色区域。有人帮忙吗?
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
_cancelButton.adjustsImageWhenHighlighted = YES;
UIImage *cancelImg = [[UIImage imageNamed:@"search_cancel_btn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0 , 11, 0, 11)];
[_cancelButton setBackgroundImage:cancelImg forState:UIControlStateNormal];
[_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_cancelButton setTitleColor:[UIColor colorWithHex:0xff666666] forState:UIControlStateNormal];
[_cancelButton setFrame:CGRectMake(264, 9.5, 52, 32)];
[_cancelButton addTarget:self action:@selector(doCancel) forControlEvents:UIControlEventTouchUpInside];
[_topSearchView addSubview:_cancelButton];