IOS UITableViewCell样式
2016-03-06 01:00
507 查看
IOS UI阶段学习 UITableView样式 UITableViewCell样式的图示
首先奉上一个通过plist文件的方式,高效,方便快捷的创建不同样式cell 的方法当我们需要定义不同类型的cell的时候,如果通过纯代码创建,可能任务量会比较大,而且效率不高,所以我举一个开发中常用到的 方法
1.首先,我们自定义一个Cell 继承自UITableViewCell 在里面封装好那些基础的东西.这些就不说了.....我在这里直接给大家呈上我今天所说的这段重点代码了
这个plist文件中的一个数组 保存的着若干个字典 (每个字典其实是包含若干个同类型的自定义cell ,添加一个键值对,指定一个cell样式的类型)
+ (UITableViewCellStyle)cellStyleWithDict:(NSDictionary *)dict
{
UITableViewCellStyle cellStyle = UITableViewCellStyleDefault;
if ([dict[@"cellStyle"] isEqualToString:@"UITableViewCellStyleSubtitle"])
{
cellStyle = UITableViewCellStyleSubtitle;
} else if ([dict[@"cellStyle"] isEqualToString:@"UITableViewCellStyleValue1"])
{
cellStyle = UITableViewCellStyleValue1;
} else if ([dict[@"cellStyle"] isEqualToString:@"UITableViewCellStyleValue2"])
{
cellStyle = UITableViewCellStyleValue2;
}
return cellStyle;
}
相信大家看到这块代码后就能想到了点什么..... 接着 在其他控制器中创建 自定义cell的时候,调用这个类方法,传入plist文件中对象的字典中的 键值,是不是就能创建出该样式的cell.
下面呈现出 UITableViewCell样式及图示
UITableView样式有两种:
1.UITableViewStylePlain:
Plain样式的是方形的,充满你给的view.frame坐标。
2.2.UITableViewStyleGrouped:
Grouped样式主要是以圆角形显示。跟iphone自带的通讯录编辑页面类似。
二、系统自己的UITableViewCell样式有四种:
1.UITableViewCellStyleDefault:
Default样式:左边一个显示图片的imageView,一个标题textLabel,没有detailTextLabel。
2.UITableViewCellStyleSubtitle:
Subtitle样式:左边一个显示图片的imageView,上边一个主标题textLabel,一个副标题detailTextLabel。主标题字体大且加黑,副标题字体小在主标题下边。
3.UITableViewCellStyleValue1:
Value1样式:左边一个显示图片的imageView,左边一个主标题textLabel,右边一个副标题detailTextLabel,主标题字体比较黑。
4.UITableViewCellStyleValue2:
Value2样式:左边一个主标题textLabel字体偏小,挨着右边一个副标题detailTextLabel,字体大且加黑。
样式图示 部分 转至 http://blog.csdn.net/crazyzhang1990/article/details/12503163
相关文章推荐
- android studio 报Error:failed to find Build Tools revision 23.0.0 rc2
- 【Monotonic-queue】【dp】【Segment-tree】【STL】Codeforces 487B - Strip
- GCD中有哪几种Queue?你自己建立过串行Queue吗?背后的线程模型是什么样的
- 如何高性能的给UIImageView加个圆角
- UIView和CALayer有什么关系
- juery学习总结(二)——juery操作页面元素
- juery学习总结(一)——juery选择器
- GuideMap 登陆界面 详细文档(四)
- Double Queue(SET水题)
- GuideMap 登录界面 详细文档(三)
- GuideMap 登陆界面 详细文档(二)
- GuideMap 登陆界面 详细文档(一)
- PAT-A1085. Perfect Sequence (25)
- 西南BANG 之 android学习笔记1——5个android UI 布局
- LeetCode96——Unique Binary Search Trees
- 334. Increasing Triplet Subsequence
- UICollectionView-Flowlayout
- Subsequence(尺取法)
- UIImage 的imageWithContentsOfFile:path和imageNamed的区别
- UESTC 1251 谕神的密码【暴力枚举】