美文网首页
iOS UITableViewCellSelectionSty

iOS UITableViewCellSelectionSty

作者: anny_4243 | 来源:发表于2016-12-09 11:20 被阅读154次

请运用如下代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor blueColor];
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;

    return cell;
}

相关文章

网友评论

      本文标题:iOS UITableViewCellSelectionSty

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