0

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];

異常なハイライト画像

4

1 に答える 1

0

これらの行を同じコードに追加してみてください。

    _cancelButton.adjustsImageWhenHighlighted = NO;
    [_cancelButton setBackgroundImage:cancelImg forState:UIControlStateHighlighted];
    [_cancelButton setTitle:@"取消" forState:UIControlStateHighlighted];
    [_cancelButton setTitleColor:[UIColor colorWithHex:0xff666666] forState:UIControlStateHighlighted];
于 2013-08-08T06:23:09.857 に答える