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来着,然后发现首页用了揭示效果,连起来用着感觉还不错. 不清楚 ...
随机推荐
- golang之指针
先上代码 package main import "fmt" type myInt int //匿名函数 //值的接收 //指针的接收 //*myint表示myInt的指针类型 / ...
- apache重启
1.进入apache下的bin目录 /usr/local/apache/bin 2.执行命令 ./apachectl graceful
- [SoapUI]怎样保存response到本地文件夹
def myOutFile = "D:/AUS/Aspect Huntley feed URLs/Automation Save Responses/ahresearch.xml" ...
- Java 设计模式系列(三)抽象工厂
Java 设计模式系列(三)抽象工厂 每天用心记录一点点.内容也许不重要,但习惯很重要!
- golang C相互调用带参数
test.h #ifndef __TEST_H__ #define __TEST_H__ void SetFunc(char* str); extern void InternalFunc(char* ...
- python sublime run快捷键设置
一.Ctrl+Shift+P进行插件“sublimeREPL”安装 二.打开preferences->Key Binding-User,写入以下内容 [ { "keys": ...
- word 2007 写CSDN博客
目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...
- http://www.rabbitmq.com/
什么是RabbitMQ 官网http://www.rabbitmq.com/ 1.应用程序间健壮的消息发送 2.简单易用 3.可在所有主流操作系统运行 4.支持巨量的开发者平台 5.开源和商用双重支持 ...
- [label][phalcon] How to install Phalcon extension for Zend Server 6.3.0 for windows 7 64bit
At first , you should download Phalcon DLL file. You can download from this link under. http://stati ...
- SqlCmd -Windows Cluster Model
前提条件 1存储lun 划分完毕并且挂载到其中一台机器上 2 需要加入群集的节点机器加入域完毕,并设置好心跳线 .加域部分可以参考 之前 Sqler Cmd 加域部分. 1检查Feature 更新 S ...