[self.tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:nil];


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
CGPoint oldPoint = [change[@"old"] CGPointValue];
CGPoint newPoint = [change[@"new"] CGPointValue];
// NSLog(@"%@",change);
CGFloat newY = newPoint.y;
CGFloat oldY = oldPoint.y;
if ( newY - oldY > 0) { //判断 self.imageView.y -= newY; self.tableView.y = self.imageView.bottom; [self.tableView setContentOffset:CGPointMake(, )]; }
else if ( newY - oldY < ) {
// self.imageView.y = self.imageView.y - newY;
// if (self.imageView.y >= 0) {
// self.imageView.y = 0;
// }
// self.tableView.y = self.imageView.bottom;
self.imageView.y -= newY; self.tableView.y = self.imageView.bottom; [self.tableView setContentOffset:CGPointMake(, )]; } }

https://github.com/yongliangP/YLSpringHeader

https://github.com/Cloudox/ScrollShowHeaderDemo

https://www.jianshu.com/p/8e4ed860d460

section 圆角 阴影

https://www.cnblogs.com/yeng/p/10540167.html

//===============Cell==================

@interface SubCell : UITableViewCell

@property (nonatomic, strong) SubCellShadowView *bgView;

@property (nonatomic, strong) NSIndexPath *indexPath;

@property (nonatomic) NSInteger rowInSection;//每一组的行数

@end

@implementation SubCell

- (void)awakeFromNib {

    [super awakeFromNib];

    self.selectionStyle = UITableViewCellSelectionStyleNone;

    self.clipsToBounds = NO;

    SubCellShadowView *bgView = [[SubCellShadowView alloc] init];

    [self insertSubview:bgView atIndex:];

    self.bgView= bgView;

    CAShapeLayer *shadow = [CAShapeLayer layer];

    shadow.shadowColor = [UIColor blackColor].CGColor;

    shadow.shadowOffset=CGSizeMake(,);

    shadow.shadowOpacity=0.15;

    [bgView.layeraddSublayer:shadow];

    bgView.shadowLayer= shadow;

    CALayer*line = [CALayerlayer];

    line.backgroundColor = [UIColor groupTableViewBackgroundColor].CGColor;

    [bgView.layeraddSublayer:line];

    bgView.separatorLine= line;

}

-(void)layoutSubviews{

    [super layoutSubviews];

    UIBezierPath*bgBezierPath =nil;

    CGFloat cornerRaduis =7.0;//觉得阴影大的可以把半径调小,半径大的话阴影面积会变大

    if(self.indexPath.row== && self.rowInSection==) {//单组单行

        self.bgView.clipsToBounds=NO;

        self.bgView.frame=self.bounds;

        CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , ));

        bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)];

    }elseif(self.indexPath.row==) {// 第一行

        self.bgView.clipsToBounds=YES;

        self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(-, , , ));

        CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , ));

        bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)];

    }elseif(self.indexPath.row==self.rowInSection-) {// 最后一行

        self.bgView.clipsToBounds=YES;

        self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(, , -, ));

        CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , ));

        bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerBottomRight)  cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)];

    }else{// 中间行

        self.bgView.clipsToBounds=YES;

        self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(, , , ));

        CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , ));

        bgBezierPath = [UIBezierPathbezierPathWithRect:rect];

    }

    self.bgView.shadowLayer.path= bgBezierPath.CGPath;

    self.bgView.shadowLayer.shadowPath= bgBezierPath.CGPath;

    self.bgView.shadowLayer.fillColor = [UIColor whiteColor].CGColor;

    //分割线 非单组单行 非最后一行

    if(!(self.indexPath.row==&&self.rowInSection==) && !(self.indexPath.row==self.rowInSection-)) {

        self.bgView.separatorLine.frame = CGRectMake(self.bgView.frame.origin.x+, self.bgView.frame.size.height-, self.bgView.frame.size.width-*, 1.0);

    }

}

@end

UITableView 头部效果/放大/移动跟随效果的更多相关文章

  1. Cocos2D实现RPG游戏人物地图行走的跟随效果

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 在一些RPG游戏中,人物队列在地图中行走的时候有时需要实现一个 ...

  2. 类似UC天气下拉和微信下拉眼睛头部弹入淡出UI交互效果(开源项目)。

    Android-PullLayout是github上的一个第三方开源项目,该项目主页是:https://github.com/BlueMor/Android-PullLayout  原作者项目意图实现 ...

  3. 不可思议的纯CSS导航栏下划线跟随效果

    先上张图,如何使用纯 CSS 制作如下效果? 在继续阅读下文之前,你可以先缓一缓.尝试思考一下上面的效果或者动手尝试一下,不借助 JS ,能否巧妙的实现上述效果. OK,继续.这个效果是我在业务开发的 ...

  4. [HTML/CSS]导航栏的下划线跟随效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 【js】鼠标跟随效果

    1.实现思想 ①鼠标跟随效果,发生在鼠标移动的时候,故需要使用onmousemove事件 ②当页面内容多于1屏时,就需要考虑滚动距离的问题 ③想实现鼠标跟随的效果需要: 元素的left位置 = 鼠标当 ...

  6. Ant Design -- 图片可拖拽效果,图片跟随鼠标移动

    Ant Design 图片可拖拽效果,图片跟随鼠标移动,需计算鼠标在图片中与图片左上角的X轴的距离和鼠标在图片中与图片左上角的Y轴的距离. constructor(props) { super(pro ...

  7. day19—纯CSS实现菜单列表下框跟随效果

    转行学开发,代码100天——2018-04-04 今天看到一篇介绍利用CSS实现列表下跟随效果的设计文章,如下图,当鼠标滑过列表项时,要求该项内容下的黑色下边框线实现同方向的跟随移动. 其中,列表内容 ...

  8. UITableView 顶部能够放大的图片

    UITableView 顶部能够放大的图片 现在有挺多的应用在 UITableView 顶部加入图片,通过拖拽 UITableView 来实现图片的放大. 对比一下腾讯出品的两款App QQ:可展示更 ...

  9. GooglePlay 首页效果----tab的揭示效果(Reveal Effect) (1)

    GooglePlay 首页效果----tab的揭示效果(Reveal Effect) (1) 前言: 无意打开GooglePlay app来着,然后发现首页用了揭示效果,连起来用着感觉还不错. 不清楚 ...

随机推荐

  1. MyBatis 实用篇(二)配置文件

    MyBatis 实用篇(二)配置文件 一.全局配置 全局配置:http://www.mybatis.org/mybatis-3/zh/configuration.html <?xml versi ...

  2. Go基本数据类型

    Go基本数据类型 第一部分:基本数据类型和操作符 1. 文件名&关键字&标识符 1. 所有go源码以.go结尾 2. 标识符以字母或下划线开头,大小写敏感,比如: a. boy  b. ...

  3. StarUML 5.0问题解决:Failed to open the model file. Invalid file format.

    使用StarUML 5.0打开一个已有的文件时,如果遇到报"Failed to open the model file. Invalid file format."错误,则原因可能 ...

  4. ZOJ2256 Mincost 2017-04-16 19:36 44人阅读 评论(0) 收藏

    Mincost Time Limit: 2 Seconds      Memory Limit: 65536 KB The cost of taking a taxi in Hangzhou is n ...

  5. HDU1102&&POJ2421 Constructing Roads 2017-04-12 19:09 44人阅读 评论(0) 收藏

    Constructing Roads Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) ...

  6. BTrace追踪Hadoop部署

    Hadoop集成BTrace 1.BTrace 1.1BTrace部署 1.下载BTrace工具包,官网地址:https://kenai.com/projects/btrace/downloads/d ...

  7. Python作图笔记

    感谢莫烦大神,附带他的个人网站链接:https://morvanzhou.github.io/ 再带上官方的文档,多看文档啊!不然参数忘了就没地方查了:https://matplotlib.org/a ...

  8. C的打印输出格式

    #include<stdio.h> int main() { float test1=12.3224356546565461-0.1; int test2=13; char test3[] ...

  9. Spring IOC 和 AOP概述

    IoC(控制反转,(Inversion of Control):本来是由应用程序管理的对象之间的依赖关系,现在交给了容器管理,这就叫控制反转,即交给了IoC容器,Spring的IoC容器主要使用DI方 ...

  10. Android-XML与JSON的理解-JSON的数据格式

    据我了解,在多年以前浏览器客户端和服务器它们的通讯数据交互格式是XML, 使用XML来规定数据格式可读性确实非常强,XML的魅力确实很大,也很成熟,但是也有不足之处,就是在网络传输的时候对流量要求特别 ...