这篇文章主要介绍了IOS UITableView颜色设置的实例详解的相关资料,这里提供了几种方法帮助大家掌握这部分内容,需要的朋友可以参考下
IOS UITableView颜色设置的实例详解
1.系统默认的颜色设置
//无色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//蓝色
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
cell.selectionStyle = UITableViewCellSelectionStyleGray;
2.自定义颜色和背景设置
改变UITableViewCell选中时背景色:
UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通过RGB来定义自己的颜色
[html] view plaincopy
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];
3自定义UITableViewCell选中时背景
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];
还有字体颜色
cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color];//设置cell的字体的颜色
4.设置tableViewCell间的分割线的颜色
[theTableView setSeparatorColor:[UIColor xxxx ]];
5、设置cell中字体的颜色
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(0 == indexPath.row)
{
cell.textLabel.textColor = ...;
cell.textLabel.highlightedTextColor = ...;
}
...
}
以上就是IOS UITableView颜色设置的几种方法,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
编程基础网
本文标题为:IOS UITableView颜色设置的实例详解
基础教程推荐
猜你喜欢
- Kotlin的枚举与异常示例详解 2022-12-07
- Android自定义view实现圆形进度条效果 2023-05-26
- Android zxing如何识别反转二维码详解 2022-11-08
- iOS统计项目的代码总行数 2022-11-01
- iOS微信分享后关闭发送成功提示并返回应用 2023-01-03
- iOS对数组进行排序的实例代码 2023-03-16
- 以代码实例总结iOS应用开发中数据的存储方式 2022-11-20
- 使用Android Studio创建OpenCV4.1.0 项目的步骤 2023-02-26
- iOS的音频文件的格式转换示例 2023-06-11
- Android自定义悬浮按钮效果 2023-04-22
