不自定义也可更改UITableViewCellSection背景颜色字体颜色
来源:互联网 发布:雷达炒股软件 编辑:程序博客网 时间:2024/06/07 18:31
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease]; if (section == integerRepresentingYourSectionOfInterest) [headerView setBackgroundColor:[UIColor redColor]]; else [headerView setBackgroundColor:[UIColor clearColor]]; return headerView;}[[UITableViewHeaderFooterView appearance] setTintColor:[UIColor redColor]];这个方法在iOS 6.0.以上都很好用。这是在标题视图添加图片的方法:- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease]; UIImageView *headerImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top-gery-bar.png"]] autorelease]; headerImage.frame = CGRectMake(0, 0, tableView.bounds.size.width, 30); [headerView addSubview:headerImage]; return headerView;}-(void) tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section { if ([view isKindOfClass: [UITableViewHeaderFooterView class]]) { UITableViewHeaderFooterView* castView = (UITableViewHeaderFooterView*) view; UIView* content = castView.contentView; UIColor* color = [UIColor colorWithWhite:0.85 alpha:1.]; // substitute your color here content.backgroundColor = color; }}- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
// 强力推荐- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{ // Background color view.tintColor = [UIColor blackColor]; // Text Color UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view; [header.textLabel setTextColor:[UIColor whiteColor]]; // header.contentView.backgroundColor = [UIColor blackColor];}通过UITableViewHeaderFooterView设置背景色的方法已经被废弃了。请用contentView.backgroundColor代替。
0 0
- 不自定义也可更改UITableViewCellSection背景颜色字体颜色
- UISegmentedControl自定义背景颜色和字体颜色
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Mac终端(Terminal)自定义颜色,字体,背景
- Android 自定义 spinner (背景、字体颜色)
- AS 自定义主题字体颜色和背景
- MFC 改变static字体颜色、大小、背景颜色【自定义类】
- MFC 改变static字体颜色、大小、背景颜色【自定义类】
- MFC 改变static字体颜色、大小、背景颜色【自定义类】
- 博客字体,颜色,背景
- eclipse字体 -背景颜色
- Hession 异常 com.caucho.hessian.io.HessianProtocolException
- 基于Tcp协议与基于Http协议的RPC简介笔记
- 正则表达式语法
- Simple-Java—Collections(一)Java高效计数器
- iOS两个app之间跳转及其传值
- 不自定义也可更改UITableViewCellSection背景颜色字体颜色
- 记不住就存下来---- HTML 5 新增的拖放 API
- iOS7中UIView的animateKeyframesWithDuration方法讲解
- 贪心算法
- 正则表达式 - 语法
- Weixin复杂数据2
- android studio cmd $ANDROID_HOME is not defined
- cmake 常用变量、常用环境变量、常用语法总结
- 端口镜像