自定义cell背景和选中时颜色
来源:互联网 发布:c语言定义函数并调用 编辑:程序博客网 时间:2024/04/28 05:41
下面两句代码即可
//cell颜色设置为白色
self.backgroundView=[[UIImageView alloc] initWithImage:[UIImage imageWithColor:[UIColor whiteColor]]];//cell选中的颜色是淡蓝色
self.selectedBackgroundView=[[UIImageView alloc] initWithImage:[UIImage imageWithColor:UIColorFromRGB(0x81b9ea)]];
说明:
// 其中的【UIColorFromRGB】是宏
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
+ (UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
以上方法是在自定义cell的.m里写的 仅供参考 看实际情况而定
0 0
- 自定义cell背景和选中时颜色
- iOS开发cell自定义高亮和选中背景颜色
- Cell选中时自定义背景
- cell被选中时的背景颜色
- ios 设置UITableView 选中行cell的背景颜色(自定义选中的背景颜色)
- 去掉cell选中背景颜色 - 芒果iOS
- 自定义cell选中时的高亮颜色
- UITableView Cell 点击时的带颜色背景效果,而不是选中颜色效果
- 两行代码自定义cell选中颜色
- iOS---选中cell时变cell颜色
- tableviewcell表视图cell选中时的颜色及背景设置,为什么无效?
- intellij idea 自定义选中字符的背景颜色和右侧滚动条上显示的颜色
- 设置ListView单击和选中背景颜色
- cell背景颜色设置
- tableViewCell 被选中时候的背景自定义和文字高亮颜色
- UISegmentedControl自定义背景颜色和字体颜色
- 更改cell选中的背景
- UITableViewCell选中时的背景颜色
- DataGrid数据转换——IValueConverter实现DataGrid数据转换
- 直接拿来用!最火的Android开源项目(二)
- opencv2 Mat分配的数据空间
- android:configChanges="keyboardHidden|orientation" 失效 Android横竖屏切换时生命周期都执行
- iOS开发Icon图标设置
- 自定义cell背景和选中时颜色
- sqlplus登录方式
- React 的 diff 算法
- VMware下的Linux系统中Windows的共享目录,不支持创建软连接
- Cron表达式详解
- java--面向对象(final,Math,String)
- Binary Tree Postorder Traversal
- PHP设计模式——单例模式
- 顶级风投First Round Capital对创业者的30个建议