根据headerView位置改变headerView颜色(collectionView/tableview)
2016-10-27 20:37
274 查看
滑动时,tableview中的headerView 的frame不断改变,collectionView的headerView的center不断改变.
so
tableview:
collectionView:
so
tableview:
-(void)setFrame:(CGRect)frame{ [super setFrame:frame]; CGRect rect = [self.superview convertRect:frame toView:[UIApplication sharedApplication].keyWindow]; if (rect.origin.y > 65 && rect.size.height > 0 && ![self.backgroundColor isEqual:[UIColor whiteColor]]) { [self setBackgroundColor:[UIColor whiteColor]]; }else if(rect.origin.y < 65 && rect.size.height > 0 && ![self.backgroundColor isEqual:UIColorFromRGB(0xff3333)]){ [self setBackgroundColor:UIColorFromRGB(0xff3333)]; }}
collectionView:
#import "CollectionReusableView.h"@interface CollectionReusableView(){ CGFloat centerY;}@end@implementation CollectionReusableView-(void)setFrame:(CGRect)frame{ [super setFrame:frame]; centerY = self.frame.origin.y + self.frame.size.height/2.0;}-(void)setCenter:(CGPoint)center{ [super setCenter:center]; if (center.y < centerY + 1 && ![self.backgroundColor isEqual:[UIColor whiteColor]]) { [self setBackgroundColor:[UIColor whiteColor]]; }else if(center.y > centerY + 1 > 0 && ![self.backgroundColor isEqual:[UIColor redColor]]){ [self setBackgroundColor:[UIColor redColor]]; }}@end
相关文章推荐
- 改变tableview section headerView 的吸顶位置
- ios:改变tableview的titleForHeaderInSection字体颜色设置
- 改变iOS7上tableview的分割线长、颜色问题
- iOS开发--改变tableHeaderView的高度
- ios开发笔记之如何让tableView根据文本内容动态改变cell的高度
- tableview 自定义cell 点击cell改变cell中的label.text的字体颜色,cell复用出现问题
- 使用tableHeaderView的时候动态改变高度
- 动态改变tableHeaderView的显示隐藏及高度
- 根据滑动改变view的大小和位置
- 改变UITableView的headerView、footerView背景颜色
- iOS 设置一行颜色不同的NSString 、剪切图片、设置TableView的自定义header
- UITableView:改变 TableHeaderView 的高度
- 【笔记】 改变 tableHeaderView 高度
- tableView位置的动态改变
- tableview cell 选中不改变颜色
- tableview 自定义cell 点击cell改变cell中的label.text的字体颜色,cell复用出现问题
- iOS tableView 改变头视图和脚视图的颜色
- 设置TableView section header的颜色
- 改变tableView中的cell选中的颜色和背景颜色 从父视图上删除所有的子视图
- iOS滑动tableView来改变导航栏的颜色