zoukankan      html  css  js  c++  java
  • UITableView属性 自己定义UITableViewCell

    UITableView的属性全齐。供大家參考 附:http://www.bubuko.com/infodetail-561085.html

    //曾经在使用UITableView的时候,总是在cell上自己加Label,遇到cellaccessoryType不同的时候,须要自己调整Label的大小和位置后来发现 UITableViewCell中有textLabeldetailTextLabel能够使用,系统配置好了大小位置,能够依据cell的不同Style和大小自己主动调整.

    //textLabel就是放置在cell左边的Label,   detailTextLabel就是放置在cell右边的Label, 使用的时候须要把cellStyle设为UITableViewCellStyleValue1.

    //代码例如以下:


    UITableViewCell *cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1reuseIdentifier:@"cell"]autorelease];

    [cell.textLabelsetText:@"选项"];

    [cell.detailTextLabelsetTextColor:[UIColor colorWithWhite:0.52alpha:1.0]];

    [cell.detailTextLabelsetText:@"具体内容"];

    cell.accessoryType =UITableViewCellAccessoryNone;//cell没有不论什么的样式

    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//UITableViewCell选中时没有不论什么的样式

    cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;//cell的右边有一个小箭头,距离右边有十几像素;

    cell.accessoryType =UITableViewCellAccessoryDetailDisclosureButton;//cell右边有一个蓝色的圆形button

    cell.accessoryType =UITableViewCellAccessoryCheckmark;//cell右边的形状是对号;

        //改变UITableViewCell选中时背景色

    cell.selectedBackgroundView = [[[UIView alloc]initWithFrame:cell.frame]autorelease];

    cell.selectedBackgroundView.backgroundColor =[UIColor redColor];

        //这样写在IOS7.0以后 TableViewCell的切割线就不会往右挫15个像素点了

       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];

    [tableViewsetSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];

  • 相关阅读:
    微信小程序 开发 微信开发者工具 快捷键
    .NET 4.0 任务(Task)
    MVC UpdateModel的未能更新XXXXX的类型模型
    ORACLE 定时执行存储过程
    DotNet 资源大全中文版(Awesome最新版)
    基于SignalR实现B/S系统对windows服务运行状态的监测
    Method not found: '!!0[] System.Array.Empty()'.
    MVC-RedirectToAction跳转到其他Area
    C# where用法
    C#委托的介绍(delegate、Action、Func、predicate)
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7029229.html
Copyright © 2011-2022 走看看