根据headerView位置改变headerView颜色(collectionView/tableview)
2024-08-26 17:02:25
滑动时,tableview中的headerView 的frame不断改变,collectionView的headerView的center不断改变.
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
最新文章
- java中的反射机制在Android开发中的用处
- addShutdownHook的用法
- sersync2 安装,配置
- 实现 Bootstrap 基本布局
- BZOJ4428 : [Nwerc2015]Debugging调试
- 【转】Ant学习笔记——自己构建Ant编译环境
- C# 之 Word光标移动 GoTo 方法
- poj3659树状DP
- Android ActionBar详解(一)--->;显示和隐藏ActionBar
- H-W平衡
- ubuntu14.04_CUDA8.0_cudnn5.1_Tensorflow配置
- 小强的Hadoop学习之路
- 求数组中最小的k个数
- MySQL NULL 值处理
- iview 菜单数据的转换,动态加载
- jdk源码阅读笔记-HashSet
- Python备份MySQL数据库【转】
- postgresql----条件表达式
- C Runtime Library、C Runtime
- js调用.net后台事件,和后台调用前台等方法总结(转帖)
热门文章
- hdoj - 1258 Sum It Up &;&; hdoj - 1016 Prime Ring Problem (简单dfs)
- Android用AutoCompleteTextView实现搜索历史记录提示
- 51nod1346 递归
- UVa 136 Ugly Numbers【优先队列】
- 自己实现内存操作函数memset(),memcmp(),memcpy(),memmove()
- Dom文档模型
- 【英语】Bingo口语笔记(28) - 表示“秘密”
- replicate-do-db参数引起的MySQL复制错误及处理办法
- jquery再学习(1)
- 【Leetcode】Evaluate Reverse Polish Notation JAVA