zoukankan      html  css  js  c++  java
  • UITableView 隔行换色 选中背景色 取消选中颜色 返回后显示正常颜色

     隔行换色

       UIView *view=[[UIViewalloc]initWithFrame:cell.frame];

        if (indexPath.row % 2==0) {

            view.backgroundColor=[UIColor blueColor];

        }

        else

        {

            view.backgroundColor=[UIColor whiteColor];

        }

        cell.backgroundView=view;

    关于选中背景色的显示以及返回正常色

    有两张实现方式 

    1  .h 基于UIviewControl

       UIView *bgsele_view=[[UIView alloc]initWithFrame:cell.frame];

        bgsele_view.backgroundColor=[UIColor redColor];

        cell.selectedBackgroundView=bgsele_view;

    取消选中颜色 返回后显示正常颜色  

    tableView  的didSelectRowAtIndexPath的事件中加入

    [tableviewdeselectRowAtIndexPath:[tableviewindexPathForSelectedRow] animated:YES];

    2  .h 基于 UITableViewController的"界面" ,默认当推送到子"界面",然后返回主“界面”,选中的颜色会自动取消,无须再进行代码的编写

  • 相关阅读:
    “正则表达式”实践日志
    一种存储数据的方法
    计划
    位运算
    ACM
    ACM-括号匹配问题
    [转]昆明长水机场安防系统应用案例分析
    Request.ServerVariables详细说明
    大数据平台的秘密
    【转】MongoDB资料汇总专题
  • 原文地址:https://www.cnblogs.com/Rampage/p/2425515.html
Copyright © 2011-2022 走看看