滑动时,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

最新文章

  1. java中的反射机制在Android开发中的用处
  2. addShutdownHook的用法
  3. sersync2 安装,配置
  4. 实现 Bootstrap 基本布局
  5. BZOJ4428 : [Nwerc2015]Debugging调试
  6. 【转】Ant学习笔记——自己构建Ant编译环境
  7. C# 之 Word光标移动 GoTo 方法
  8. poj3659树状DP
  9. Android ActionBar详解(一)---&gt;显示和隐藏ActionBar
  10. H-W平衡
  11. ubuntu14.04_CUDA8.0_cudnn5.1_Tensorflow配置
  12. 小强的Hadoop学习之路
  13. 求数组中最小的k个数
  14. MySQL NULL 值处理
  15. iview 菜单数据的转换,动态加载
  16. jdk源码阅读笔记-HashSet
  17. Python备份MySQL数据库【转】
  18. postgresql----条件表达式
  19. C Runtime Library、C  Runtime
  20. js调用.net后台事件,和后台调用前台等方法总结(转帖)

热门文章

  1. hdoj - 1258 Sum It Up &amp;&amp; hdoj - 1016 Prime Ring Problem (简单dfs)
  2. Android用AutoCompleteTextView实现搜索历史记录提示
  3. 51nod1346 递归
  4. UVa 136 Ugly Numbers【优先队列】
  5. 自己实现内存操作函数memset(),memcmp(),memcpy(),memmove()
  6. Dom文档模型
  7. 【英语】Bingo口语笔记(28) - 表示“秘密”
  8. replicate-do-db参数引起的MySQL复制错误及处理办法
  9. jquery再学习(1)
  10. 【Leetcode】Evaluate Reverse Polish Notation JAVA