Ios 选择行时禁用uitableviewcell中的高亮显示按钮
我有自定义UITableViewCell和两个按钮。当我选择行时,按钮的背景会改变为和所选行的背景相同的颜色,按钮的边框也会消失 选择行时,如何禁用更改按钮的边框/背景色Ios 选择行时禁用uitableviewcell中的高亮显示按钮,ios,objective-c,uitableview,cocoa-touch,Ios,Objective C,Uitableview,Cocoa Touch,我有自定义UITableViewCell和两个按钮。当我选择行时,按钮的背景会改变为和所选行的背景相同的颜色,按钮的边框也会消失 选择行时,如何禁用更改按钮的边框/背景色 感谢您的回复,我使用了一个清晰的单元格背景视图并禁用了行的选择颜色,实现了这一点,但我需要这样做。不知道是否适合您的需要,但您可以尝试以下方法: UIView *selectedView = [[UIView alloc] initWithFrame:cell.bounds]; selectedView.backgroundC
感谢您的回复,我使用了一个清晰的单元格背景视图并禁用了行的选择颜色,实现了这一点,但我需要这样做。不知道是否适合您的需要,但您可以尝试以下方法:
UIView *selectedView = [[UIView alloc] initWithFrame:cell.bounds];
selectedView.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = selectedView;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
希望这有帮助
也要签出此线程:1)创建UIView并指定所需的背景色。
2) 将UIView渲染为UIImage
3) 将按钮的背景图像设置为所需状态
UIView *colorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
colorView.backgroundColor = color;
UIGraphicsBeginImageContext(colorView.bounds.size);
[colorView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *colorImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[button setBackgroundImage:colorImage forState: UIControlStateHighlighted];