zoukankan      html  css  js  c++  java
  • (十五)UITableViewCell的常见属性

    UItableViewCellStyle:

    typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
        UITableViewCellStyleDefault,	//左边imageView,右边显示textLabel
        UITableViewCellStyleValue1,		// 左边显示imageView,右边显示textLabel与detailTextLabel(横排)
        UITableViewCellStyleValue2,		// 左边显示蓝色的textLabel,右边显示黑色的detailTextLabel
        UITableViewCellStyleSubtitle	// 左边显示imageView,有textLabel和detailTextLabel(竖排)
    };

    accessoryType属性,右边的指示器(如箭头,指示用户点击后跳转)。

    它是枚举类型,一共有5种。

    typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) {
        UITableViewCellAccessoryNone,                   // 无
        UITableViewCellAccessoryDisclosureIndicator,    // 向右的指示箭头
        UITableViewCellAccessoryDetailDisclosureButton, // 对号 + 向右的指示箭头
        UITableViewCellAccessoryCheckmark,              // 对号
        UITableViewCellAccessoryDetailButton NS_ENUM_AVAILABLE_IOS(7_0) // 带圈的i标志(iOS7.0开始支持)
    };

    Tip:访问资源库(Library)文件夹的方法,按住option键选择Finder的菜单可以看到灰色的library选项,点开即可。

    Tip:发现Xcode报错头文件被修改,可以通过清理缓存实现,打开Library/Developer/Xcode 删除DerivedData文件夹。

    如果系统自带的样式不够用,还可以自己定义样式,使用accessoryView属性,可以自己加入控件,例如加入一个开关。

    Tip:经常打开的文件夹可以制作替身(alias,类似于windows快捷方式)来快速访问。

    cell.accessoryView = [[UISwitch alloc] init];

    Tip:有固定尺寸的控件是无法修改固定的尺寸的。

    backgroundView与selectedbackgroundView可以设定普通和点选的样式。也可以使用backgroundColor设置,但是前者优先级高。

    设定颜色:

    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor grayColor];
    cell.backgroundView = bgView;
        
    UIView *bgViewSelceted = [[UIView alloc] init];
    bgViewSelceted.backgroundColor = [UIColor brownColor];
    cell.selectedBackgroundView = bgViewSelceted;

    注意一个细节,UIView必须创建两次,如果只创建一个,在对选中的背景色设置前更换backgroundColor,会使得第一个设置失效

    也可以直接设定图片,backgrounView可以接受任何类型的UIView,因此也可以接收UIImageView。

    Tip:系统会自动填充,不用将背景设置尺寸。尽量使用backgroundView而不是Color。


  • 相关阅读:
    UBUNTU开机时出现“waiting for network configuration” 问题的解决 (转) 沉沉_
    模拟地与数字地(转) 沉沉_
    转 parsing error:expected ")" 解决方法 沉沉_
    转 按Enter键或者ESC键,程序退出的解决方法 沉沉_
    C语言中的常量 沉沉_
    TI C64X DSP中断向量表的配置(硬件中断) 转自新浪博客 沉沉_
    只用串口和网络裸机开发ARM程序(OK6410开发板) 沉沉_
    ubuntu 上开启 网络文件系统(NFS) 沉沉_
    Visual Studio 2010 Express for Windows Phone 新建项目时为何不显示 XNA
    Win32汇编菜单进阶之右键弹出菜单
  • 原文地址:https://www.cnblogs.com/aiwz/p/6154238.html
Copyright © 2011-2022 走看看