- 浏览: 18023 次
- 性别:
- 来自: 北京
最新评论
1.给tableviewcell添加label,首先
然后可以定义label的一些属性
label.backgroundColor = [UIColor grayColor]; //设置背景色
label.text = @"Hello World"; //设置内容
label.textColor = [UIColor blueColor]; //文本颜色
label.backgroundColor = [UIColor clearColor]; //设置label的背景色透明
在这我添加的前三行颜色不一样
若把[cell.contentView addSubview:label];改为[self.view addSubview:label]则label将建立在tableview中,而不是tableviewcell中
2.给tableviewcell添加button
常用的button的属性
button.frame = CGRectMake(150,30,50,20);//button的位置
[button setTitle:@"点击" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blackColor];
3在cell创建image
还有一种办法
用这个办法该图片显示在cell最左侧imageview中
CGRect labelRect = CGRectMake(X, Y,length, width);//x、y表示位置 UILabel *label = [[UILabel alloc] initWithFrame:labelRect];
然后可以定义label的一些属性
label.backgroundColor = [UIColor grayColor]; //设置背景色
label.text = @"Hello World"; //设置内容
label.textColor = [UIColor blueColor]; //文本颜色
label.backgroundColor = [UIColor clearColor]; //设置label的背景色透明
在这我添加的前三行颜色不一样
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifier = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil){ cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; //创建label CGRect labelRect = CGRectMake(120, 10,130, 20); UILabel *label = [[UILabel alloc] initWithFrame:labelRect]; label.text = @"hello world!!!"; label.textColor = [UIColor redColor]; [cell.contentView addSubview:label]; label.font = [UIFont boldSystemFontOfSize:16]; } return cell; }
若把[cell.contentView addSubview:label];改为[self.view addSubview:label]则label将建立在tableview中,而不是tableviewcell中
2.给tableviewcell添加button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
常用的button的属性
button.frame = CGRectMake(150,30,50,20);//button的位置
[button setTitle:@"点击" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blackColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(150,30,50,20); [button setTitle:@"点击" forState:UIControlStateNormal]; button.backgroundColor = [UIColor blackColor]; cell.accessoryView = button;
3在cell创建image
UIImage *image = [UIImage imageNamed:@"meitu@2x.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.frame = CGRectMake(50, 10, 45, 45); [cell.contentView addSubview:imageView];
还有一种办法
cell.imageView.image = [UIImage imageNamed:@"meitu@2x.png"];
用这个办法该图片显示在cell最左侧imageview中
发表评论
-
css兼容问题
2018-02-26 13:14 3701. 就是 ie6 双倍边距的问题,在使用了 float 的情 ... -
css
2018-02-23 11:06 4041.#nav li {} 看起来很快,实际上很慢,尽管这让人 ... -
web标准
2018-02-22 14:25 376web标准简单来说可以分为结构、表现和行为。其中结构主要是有H ... -
总结一些每次写都要百度的样式 and so on
2016-06-03 14:00 450本次总结无关乎顺序, ... -
js检测css样式的兼容问题
2015-07-24 20:30 821<script> ... -
canvas画布基础
2015-07-10 20:47 410canvas是个神奇的标签,开始学习之后就停不下来,这两天一直 ... -
PHP正则表达式
2015-07-07 14:34 422正则表达式的基本语法 ... -
PHP字符串与数组常用函数
2015-07-07 10:42 1948字符串: 字符串的连接:PHP中用英文的点号.来连接两个字符串 ... -
DOM事件对象event、IE中的事件对象
2015-07-02 16:45 478DOM中的事件对象: type属性用于获取事件类型; targ ... -
跨浏览器事件处理程序
2015-07-02 16:03 463<div id = "box"& ... -
jQuery获取父级元素、同级元素、子元素、过滤
2015-07-01 15:50 476父级元素: <body>body (曾曾祖父) ... -
点击按钮实现轮播切换
2015-06-29 19:13 978HTML: <div class="con3 ... -
jQuery验证邮箱手机
2015-06-29 19:03 493验证邮箱: function checkSignEmail ... -
ios多线程
2014-11-27 14:35 440最近写了一个东西需要加载网络上的图片,运行的时候一直卡到一个界 ... -
取出数组中的值
2014-11-01 21:08 296在写程序的时候,遇到一个问题,想把数组[a,b]中的a,b添加 ... -
解析json获取数据
2014-11-01 20:57 374NSError *error; NSURLReq ... -
cell重用问题
2014-11-01 20:44 548解决问题之前,在cell上添加了label,但是给label添 ... -
保存并获取数据
2014-09-27 19:38 289在IOS开发过程中,经常会遇到数据保存的问题,现在主要说一下用 ... -
UINavigationController实现页面跳转
2014-09-19 20:31 764总结一下利用navigationController push ... -
简单表视图并实现添加数据
2014-09-10 19:21 13051.基础:表用于显示数据列表。数据列表中的每项都由行表示。表视 ...
相关推荐
iOS8新功能 TableViewCell滑动添加多个按钮,以后就不用自己计算位置了
tableviewcell的移动、删除、添加
最近项目上出现了这种需要在一个cell上多个button的处理问题以及自己在项目中遇到的重用的问题,这也是开发中比较常见的功能和出现的问题,遂在此记录. 附上简书地址:http://www.jianshu.com/p/a00540e2fbdd 大家...
在UITableView中给每个UITableViewCell添加一个长按手势,在长按手势触发时,不会触发tableview的didSelectRowAtIndexPath方法,这样就不知道长按的是哪个cell,有一种简单的方法可以获得cell所在的indexPath。
swift简单的自定义tableViewCell实现
自定义符合要求饿到cell,让你的tableview更加适用
通过Block实现TableViewCell上button的点击事件.
iOS TableViewCell 组件,选择单元格,然后显示一个下拉的详情信息。
NULL 博文链接:https://hua397.iteye.com/blog/910395
uitableviewcell 高度自适应代码demo,喜欢的可以看看,也可以一起讨论下,有什么更好的方法来解决这个问题。
tableviewcell的风格改变默认的选中效果蓝色,可自定义cell的选中背景色
用Swift语言实现了自定义tableViewCell。 包含了一个TableViewCell的基类以及自定义的tableViewCell类的实现和调用。
一款关于UITableView滑动时的动画,效果大概是上下滑动时,cell飞入或者淡入淡出这种效果,也可以根据这个效果的实现思路实现其他的效果,效果图没法上传,自己下载看下吧
ios TableViewCell收缩、伸缩、缩放功能
在UITableViewCell里面加入自定义控件,本文以Lable为例,给读者提供一种动态控制Cell高度的思想,由这种思想出发,读者可以以此来动态控制cell的高度。
用于tableViewCell 和 collectionViewCell 的移动 如发现问题请发邮件至ranheran@sohu.com,我会尽快修正
https://github.com/amber01/WSHorizontalListView.git ,在UITableViewCell中添加横向滚动视图,用于展示不同图片。利用UICollectionView的优点,从而性能上有很大优化
用Swift实现的简单自定义TableViewCell
tableViewCell图片lazyload 图片延迟加载
简单的tableViewCell的展开和收起,仿好友列表,自定义cell的内容。简单易懂,适合新手学习。