iOS UITableViewCellSelectionStyleBlue 不起作用怎么办

请运用如下代码:

- (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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,647评论 25 708
  • 墙头的狗尾巴 遗忘在角落,不被人了解 不曾有谁留恋过 每当静静的夜 你独自黯然 只有微风懂你的心事 吹动你的芳心 ...
    唐春元ok阅读 235评论 11 13
  • 近日要下些图像数据做实验,奈何几个G的数据经常断线。搞到这篇良心贴,亲测可行,分享给大家。http://xclie...
    _CelesteHuang_阅读 779评论 0 1
  • 我觉得人工智能在相当长的短期内会给人类带来极大的便利,但是在以后的以后其实对人类是起负面作用的。 现在智能家居等人...
    尾生斯基阅读 308评论 0 2
  • 昨天看了电影《辩护人》,感觉十分复杂。 印象深刻的有两处:一是少年睁着清亮的眼睛说:石头再硬也是死的,鸡蛋再软却是...
    秋雨霜荷阅读 391评论 1 1