iOS-为UITableViewCell添加详情指示图,和说明文字
2016-03-25 10:40
471 查看
一、创建数据源
self.menuArray = [[NSMutableArrayalloc]
initWithCapacity:0];
NSArray *m1Array =@[@{@"name":@"消息中心",@"icon":@"xxzx",@"ctr":@"CYMessageListViewController"},
@{@"name":@"设置",@"icon":@"set",@"ctr":@"MCSettingViewController"}];
[self.menuArrayaddObject:m1Array];
二、创建UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath{
static
NSString *Identifier =@"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:Identifier];
[[cell viewWithTag:10]removeFromSuperview];
[[cell viewWithTag:20]removeFromSuperview];
if (!cell) {
cell = [[UITableViewCellalloc]
initWithStyle:UITableViewCellStyleValue1reuseIdentifier:Identifier];
cell.backgroundColor = [UIColorwhiteColor];
}
NSArray *funcArray =
self.menuArray[indexPath.section];
NSDictionary *menuDit = funcArray[indexPath.row];
cell.textLabel.text = menuDit[@"name"];
cell.textLabel.font = [UIFontsystemFontOfSize:15];
[cell.imageViewsetImage:[UIImageimageNamed:menuDit[@"icon"]]];
cell.detailTextLabel.textColor=EHMO_COLOR_TEXT;
UIImageView *accessoryView=[[UIImageViewalloc]initWithFrame:CGRectMake(WIDTH-30,12.5,
20, 20)];
accessoryView.tag=10;
accessoryView.image=[UIImageimageNamed:@"btn-more_g@2x"];
[celladdSubview:accessoryView];
UILabel *detailLabel=[[UILabelalloc]
initWithFrame:CGRectMake(WIDTH-130,2.5,
100, 40)];
detailLabel.backgroundColor=[UIColorwhiteColor];
detailLabel.font=[UIFontsystemFontOfSize:13];
detailLabel.textAlignment=NSTextAlignmentRight;
detailLabel.textColor=[UIColorgrayColor];
detailLabel.tag=20;
[celladdSubview:detailLabel];
return cell;
}
实现效果图:
self.menuArray = [[NSMutableArrayalloc]
initWithCapacity:0];
NSArray *m1Array =@[@{@"name":@"消息中心",@"icon":@"xxzx",@"ctr":@"CYMessageListViewController"},
@{@"name":@"设置",@"icon":@"set",@"ctr":@"MCSettingViewController"}];
[self.menuArrayaddObject:m1Array];
二、创建UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath{
static
NSString *Identifier =@"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:Identifier];
[[cell viewWithTag:10]removeFromSuperview];
[[cell viewWithTag:20]removeFromSuperview];
if (!cell) {
cell = [[UITableViewCellalloc]
initWithStyle:UITableViewCellStyleValue1reuseIdentifier:Identifier];
cell.backgroundColor = [UIColorwhiteColor];
}
NSArray *funcArray =
self.menuArray[indexPath.section];
NSDictionary *menuDit = funcArray[indexPath.row];
cell.textLabel.text = menuDit[@"name"];
cell.textLabel.font = [UIFontsystemFontOfSize:15];
[cell.imageViewsetImage:[UIImageimageNamed:menuDit[@"icon"]]];
cell.detailTextLabel.textColor=EHMO_COLOR_TEXT;
UIImageView *accessoryView=[[UIImageViewalloc]initWithFrame:CGRectMake(WIDTH-30,12.5,
20, 20)];
accessoryView.tag=10;
accessoryView.image=[UIImageimageNamed:@"btn-more_g@2x"];
[celladdSubview:accessoryView];
UILabel *detailLabel=[[UILabelalloc]
initWithFrame:CGRectMake(WIDTH-130,2.5,
100, 40)];
detailLabel.backgroundColor=[UIColorwhiteColor];
detailLabel.font=[UIFontsystemFontOfSize:13];
detailLabel.textAlignment=NSTextAlignmentRight;
detailLabel.textColor=[UIColorgrayColor];
detailLabel.tag=20;
[celladdSubview:detailLabel];
return cell;
}
实现效果图:
相关文章推荐
- GUI - Web前端开发框架
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Cocos2d-x UI开发之文本类使用实例
- 谈谈对jquery ui tabs 的理解
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- UI Events 用户界面事件
- jquery UI Datepicker时间控件的使用方法(基础版)
- Hallo.js基于jQuery UI所见即所得的Web编辑器
- 基于jQuery UI CSS Framework开发Widget的经验
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- jQuery UI设置固定日期选择特效代码分享
- Jquery ajax 同步阻塞引起的UI线程阻塞问题