UITableView 头部效果/放大/移动跟随效果
[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 头部效果/放大/移动跟随效果的更多相关文章
- Cocos2D实现RPG游戏人物地图行走的跟随效果
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 在一些RPG游戏中,人物队列在地图中行走的时候有时需要实现一个 ...
- 类似UC天气下拉和微信下拉眼睛头部弹入淡出UI交互效果(开源项目)。
Android-PullLayout是github上的一个第三方开源项目,该项目主页是:https://github.com/BlueMor/Android-PullLayout 原作者项目意图实现 ...
- 不可思议的纯CSS导航栏下划线跟随效果
先上张图,如何使用纯 CSS 制作如下效果? 在继续阅读下文之前,你可以先缓一缓.尝试思考一下上面的效果或者动手尝试一下,不借助 JS ,能否巧妙的实现上述效果. OK,继续.这个效果是我在业务开发的 ...
- [HTML/CSS]导航栏的下划线跟随效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【js】鼠标跟随效果
1.实现思想 ①鼠标跟随效果,发生在鼠标移动的时候,故需要使用onmousemove事件 ②当页面内容多于1屏时,就需要考虑滚动距离的问题 ③想实现鼠标跟随的效果需要: 元素的left位置 = 鼠标当 ...
- Ant Design -- 图片可拖拽效果,图片跟随鼠标移动
Ant Design 图片可拖拽效果,图片跟随鼠标移动,需计算鼠标在图片中与图片左上角的X轴的距离和鼠标在图片中与图片左上角的Y轴的距离. constructor(props) { super(pro ...
- day19—纯CSS实现菜单列表下框跟随效果
转行学开发,代码100天——2018-04-04 今天看到一篇介绍利用CSS实现列表下跟随效果的设计文章,如下图,当鼠标滑过列表项时,要求该项内容下的黑色下边框线实现同方向的跟随移动. 其中,列表内容 ...
- UITableView 顶部能够放大的图片
UITableView 顶部能够放大的图片 现在有挺多的应用在 UITableView 顶部加入图片,通过拖拽 UITableView 来实现图片的放大. 对比一下腾讯出品的两款App QQ:可展示更 ...
- GooglePlay 首页效果----tab的揭示效果(Reveal Effect) (1)
GooglePlay 首页效果----tab的揭示效果(Reveal Effect) (1) 前言: 无意打开GooglePlay app来着,然后发现首页用了揭示效果,连起来用着感觉还不错. 不清楚 ...
随机推荐
- C#重启IIS
using System.Diagnostics; using System.ServiceProcess; //ServiceController sc1 = new ServiceControll ...
- linux下mysql开启远程访问权限及防火墙开放3306端口(mysql开放host访问权限)
开启mysql的远程访问权限默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限.主流的有两种方法,改表法和授权法.相对而言,改表法 ...
- Halcon阈值化算子dual_threshold和var_threshold的理解
Halcon中阈值二值化的算子众多,通常用得最多的有threshold.binary_threshold.dyn_threshold等. threshold是最简单的阈值分割算子,理解最为简单:bin ...
- cocos2dx中使用tolua++使lua调用c++函数
一直想学学cocos2dx中如何使用tolua++工具使得lua脚本调用C++函数,今天就来搞一下,顺便记录下来: 首先,我们打开cocos2dx-2.2.4中projects下的test的VS工程, ...
- Scheduling the Delivery of Local Notifications
[Scheduling the Delivery of Local Notifications] Apps can use local notifications to display alerts, ...
- spark standalone集群部署 实践记录
本文记录了一次搭建spark-standalone模式集群的过程,我准备了3个虚拟机服务器,三个centos系统的虚拟机. 环境准备: -每台上安装java1.8 -以及scala2.11.x (x代 ...
- C++中函数模版与类模版
1.什么是模板? (1)可以这样来解释这个问题,例如当我们需要定义多个函数,而这个函数功能其实都是一样的,例如两个数相加的函数, 只是相加的两个数的类型不相同而已,这就导致我们需要定义多个函数:当我们 ...
- http应答码
1xx - 信息提示 这些状态代码表示临时的响应.客户端在收到常规响应之前,应准备接收一个或多个 1xx 响应.· 100 - Continue 初始的请求已经接受,客户应当继续发送请求的其余部分.( ...
- HDU1879 继续畅通工程 2017-04-12 19:12 50人阅读 评论(0) 收藏
继续畅通工程 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submis ...
- Chain Of Responsibility Design Pattern Example
Avoid coupling the sender of a request to the receiver by giving more than one object a chance to ha ...