美文网首页
自定义UITableViewCell的点击样式

自定义UITableViewCell的点击样式

作者: LearningCoding | 来源:发表于2016-07-02 19:30 被阅读708次
    // 首先在tableView的代理方法中设置cell的选中样式为none
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        WXOrderStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELL" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
    // 在重写的cell里面
    // 重写setHighlighted方法
    - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
    {
        if (highlighted == YES) {
            // 选中时候的样式
            self.bgView.backgroundColor = WColorRGB(240, 240, 240);
            
        } else {
            // 未选中时候的样式
            self.bgView.backgroundColor = [UIColor whiteColor];
        }
    }
    

    相关文章

      网友评论

          本文标题:自定义UITableViewCell的点击样式

          本文链接:https://www.haomeiwen.com/subject/psvqjttx.html