Ios Can';t在UITableView中选择后更改分隔符(自定义UIView)颜色
我在点击后改变单元格颜色,我也在改变单元格底部的小自定义分隔符。但是,当我调用Ios Can';t在UITableView中选择后更改分隔符(自定义UIView)颜色,ios,iphone,uitableview,Ios,Iphone,Uitableview,我在点击后改变单元格颜色,我也在改变单元格底部的小自定义分隔符。但是,当我调用deselerowatinexpath时,分隔符颜色将恢复为忽略更改之前的颜色。为什么会发生这种情况,我如何完成这个简单的任务? 这是我的密码: [tableView deselectRowAtIndexPath:indexPath animated:NO]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *sep
deselerowatinexpath
时,分隔符颜色将恢复为忽略更改之前的颜色。为什么会发生这种情况,我如何完成这个简单的任务?
这是我的密码:
[tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIView *separator = [cell viewWithTag:SEPARATOR];
separator.backgroundColor = _colorOrangeSelected;
以下是一个解决方案:
- 将
拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置UIImageView
和图像
高光图像
- 将
拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置UIImageView
和图像
高光图像
- 将
拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置UIImageView
和图像
高光图像
- 将
拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置UIImageView
和图像
高光图像
选中单元格后,自定义单元格将自动刷新子视图状态,但您必须准备两张图像。UIView不能使用highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
if (self.cellDevideLineColor != nil) {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.cellDevideLineColor set];
CGContextSetLineWidth(context, kCellLineHeight);
CGContextMoveToPoint(context, 0, rect.size.height);
CGContextAddLineToPoint(context, self.width, rect.size.height);
CGContextStrokePath(context);
}
}
UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
if (self.cellDevideLineColor != nil) {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.cellDevideLineColor set];
CGContextSetLineWidth(context, kCellLineHeight);
CGContextMoveToPoint(context, 0, rect.size.height);
CGContextAddLineToPoint(context, self.width, rect.size.height);
CGContextStrokePath(context);
}
}
UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
if (self.cellDevideLineColor != nil) {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.cellDevideLineColor set];
CGContextSetLineWidth(context, kCellLineHeight);
CGContextMoveToPoint(context, 0, rect.size.height);
CGContextAddLineToPoint(context, self.width, rect.size.height);
CGContextStrokePath(context);
}
}
UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
if (self.cellDevideLineColor != nil) {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.cellDevideLineColor set];
CGContextSetLineWidth(context, kCellLineHeight);
CGContextMoveToPoint(context, 0, rect.size.height);
CGContextAddLineToPoint(context, self.width, rect.size.height);
CGContextStrokePath(context);
}
}
我通过为我的单元格子类化
UITableViewCell
,并重写setSelected
和setHighlighted
方法,解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态 我通过为我的单元格子类化UITableViewCell
并重写setSelected
和setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态 我通过为我的单元格子类化UITableViewCell
并重写setSelected
和setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态 我通过为我的单元格子类化UITableViewCell
并重写setSelected
和setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态