iOS集合视图UICollectionViewCell的选种(高亮)效果
来源:互联网 发布:淘宝运费模板如何删除 编辑:程序博客网 时间:2024/05/24 02:15
当我们使用集合视图UICollectionView时,往往需要给UICollectionViewCell的点击事件加一个跟UIButton一样的高亮效果,否则用户会觉得其实自己压根没点中一样,这样无形之中便降低了用户体验,今天我来说说如何给集合视图UICollectionViewCell的选种添加高亮效果。
直接看代码吧:
//当cell高亮时返回是否高亮- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath{ return YES;}- (void)collectionView:(UICollectionView *)colView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{ UICollectionViewCell* cell = [colView cellForItemAtIndexPath:indexPath]; //设置(Highlight)高亮下的颜色 [cell setBackgroundColor:[UIColor colorWithString:@"f2f2f2"]];}- (void)collectionView:(UICollectionView *)colView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath{ UICollectionViewCell* cell = [colView cellForItemAtIndexPath:indexPath]; //设置(Nomal)正常状态下的颜色 [cell setBackgroundColor:[UIColor whiteColor]];}
1 0
- iOS集合视图UICollectionViewCell的选种(高亮)效果
- iOS集合视图单元格高亮和选中的区别
- 应用集合视图(UICollectionView)-创建UICollectionViewCell子类单元格
- iOS 视图高斯模糊(毛玻璃)效果实现
- IOS中UICollectionViewCell的问题
- iOS设置UICollectionViewCell的间距
- iOS UICollectionViewCell 的 contentView 注意事项
- iOS 视图的模糊效果
- iOS UICollectionViewCell点击无响应的解决方法
- iOS UICollectionViewCell上有Button点击实现收藏效果
- IOS自定义UICollectionViewCell(对比UITableViewCell)
- IOS自定义UICollectionViewCell(对比UITableViewCell)
- UICollectionViewCell重用注意要点(解决视图重叠问题)
- UICollectionViewCell水平缩放,中间大两边小效果的实现
- iOS中UICollectionView(集合视图)的使用
- iOS 设置视图的圆角效果
- 去掉回退时被选种的行
- iOS 自定义UICollectionViewCell
- ABAP内外日期转换
- Longest Valid Parentheses
- Java WorkSet View
- 理解RESTful架构
- php字符串函数(3)
- iOS集合视图UICollectionViewCell的选种(高亮)效果
- R语言安装
- 字典序最小问题——Best Cow Line
- vsftp安装和配置
- Hibernate和IBatis对比(优缺点)
- 万言万当,不如一默为官之道
- Linux cmake安装,配置以及测试
- 2015.5.19搁置
- Curl