ios 试图滚动的时候,顶部显示和隐藏动画效果
来源:互联网 发布:java参数的传递 编辑:程序博客网 时间:2024/06/06 08:27
@interface HeadrView : UIView
@property (nonatomic,strong) UIScrollView *scrollView;
@end
#import "HeadrView.h"
#import "Masonry.h"
@interface HeadrView ()<UIScrollViewDelegate>
{
CGFloat topHeight;
CGFloat bottomHeight;
CGFloat sumHeight;
UIView *topView;
UIView *bottomView;
CGFloat beginContentY; //开始滑动的位置
}
@end
@implementation HeadrView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self)
{
topHeight = 64;
bottomHeight =170;
sumHeight = -bottomHeight-topHeight;
topView = [UIViewnew];
topView.backgroundColor = [UIColorredColor];
bottomView = [UIViewnew];
bottomView.backgroundColor = [UIColorlightGrayColor];
[self addSubview:topView];
[self addSubview:bottomView];
[topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_top);
make.left.equalTo(self.mas_left);
make.right.equalTo(self.mas_right);
make.height.equalTo(@(64));
}];
[bottomViewmas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(topView.mas_bottom);
make.left.equalTo(self.mas_left);
make.right.equalTo(self.mas_right);
make.height.equalTo(@(170));
}];
self.clipsToBounds =YES;
[self.layersetMasksToBounds:YES];
}
return self;
}
- (void)willMoveToSuperview:(UIView *)newSuperview
{
self.scrollView.contentInset =UIEdgeInsetsMake(bottomHeight+topHeight,0, 0,0);
self.scrollView.delegate =self;
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
beginContentY = scrollView.contentOffset.y; //开始滑动的位置
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inoutCGPoint *)targetContentOffset
{
CGFloat endContentY = scrollView.contentOffset.y;
if (endContentY-beginContentY >=0)
{
[UIViewanimateWithDuration:0.25animations:^{
self.alpha =0;
self.frame =CGRectMake(0,sumHeight, self.frame.size.width,self.frame.size.height);
self.scrollView.contentInset =UIEdgeInsetsMake(0,0, 0, 0);
} completion:^(BOOL finished) {
}];
}
else
{
[UIViewanimateWithDuration:0.25animations:^{
self.alpha =1;
self.frame =CGRectMake(0,0, self.frame.size.width,self.frame.size.height);
self.scrollView.contentInset =UIEdgeInsetsMake(bottomHeight+topHeight,0, 0,0);
} completion:^(BOOL finished) {
}];
}
}
- ios 试图滚动的时候,顶部显示和隐藏动画效果
- Android 动画1--View控件的显示和隐藏效果
- Android 动画1--View控件的显示和隐藏效果
- Android 动画1--View控件的显示和隐藏效果
- JQuery 动画显示和隐藏效果
- JQuery 动画显示和隐藏效果
- 控件隐藏/显示时的动画效果
- 在列表滚动的时候显示或者隐藏Toolbar
- iOS控件的动画显示与隐藏
- Silverlight 显示隐藏动画效果
- 隐藏/显示界面动画效果
- jQuery之动画效果(动画基础隐藏和显示,上卷下拉效果 ,淡入淡出效果 ,动画切换的比较,自定义动画,jQuery核心)
- Android 监听scrollview滚动实现ToolBar显示和隐藏的效果
- jquery实现返回顶部按钮和scroll滚动功能[带动画效果] 转载
- jquery实现返回顶部按钮和scroll滚动功能[带动画效果]
- android 控件显示和隐藏时增加动画效果
- android布局中子View添加动态隐藏和显示的动画效果。(LayoutTransition)
- Android WebView 滚动方向判断同时底部导航栏隐藏或显示(动画效果)
- LeetCode 2.Add Two Numbers
- Dubbo架构的学习之旅
- C++ 升级编译器gcc 4.7或者以上版本
- weblogic的oracle的驱动包解释
- Android内存泄露和GC机制
- ios 试图滚动的时候,顶部显示和隐藏动画效果
- 100+经典Java面试题及答案解析
- LeetCode 19.Remove Nth Node From End of List
- Openstack Neutron DVR 分布式路由
- git提交项目出错
- 关于MySQL的四种外键约束
- Hadoop回顾:(二)搭建5节点hadoop集群环境(CDH5)
- ubuntu安装python3.5
- Android移动开发者必须知道的Deep Linking技术