iOS 弹出界面抖动动画

QQ20190215-161612-HD.gif

思路:


image.png

其中D点是可动的, 其他点都是固定不变的, 哎. 其他思路感觉看代码就可以了, 还是得增强语言沟通能力, 说不出来, 看代码吧~😂😂😂, 应该很好理解的

//
//  JC_DrawerController.m
//  JUNCHUANG
//
//  Created by WYC on 2019/2/14.
//  Copyright © 2019年 WYC. All rights reserved.
//弹出的抽屉菜单

#import "JC_DrawerController.h"

@interface JC_DrawerController()

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, assign) CGPoint pointD;

@property (nonatomic, strong) CADisplayLink *displayLink;

@property (nonatomic, strong) CAShapeLayer *shapeLayer;

@property (nonatomic, strong) UIView *view2;

@end

@implementation JC_DrawerController

-(void)viewDidLoad{
[super viewDidLoad];

self.view.backgroundColor = [UIColor clearColor];


UIBlurEffect *blurEffect =[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView =[[UIVisualEffectView alloc]initWithEffect:blurEffect];
effectView.frame = CGRectMake(0,
                             0, 170,JC_SCREENHEIGHT);

[self.view addSubview:effectView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
effectView.userInteractionEnabled = YES;

[effectView addGestureRecognizer:tap];

}

-(void)tapAction{
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
 [self setAnimation];
}

-(UITableView *)tableView{
if (!_tableView) {
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(150, 0, JC_SCREENWIDTH - 150, JC_SCREENHEIGHT) style:(UITableViewStylePlain)];
//        _tableView.backgroundColor = [UIColor orangeColor];
    }
return _tableView;
}


-(void)setAnimation{

self.pointD = CGPointMake(70, JC_SCREENHEIGHT * 0.5);
UIView *view1 = [[UIView alloc] init];
view1.center = self.pointD;
view1.bounds= CGRectMake(0, 0, 10, 10);
view1.backgroundColor = [UIColor clearColor];
[self.view addSubview:view1];
self.view2 = view1;
[UIView animateWithDuration:3.0 delay:0.0 usingSpringWithDamping:0.2 initialSpringVelocity:0.1 options:(UIViewAnimationOptionCurveEaseInOut) animations:^{
    self.pointD = CGPointMake(150, JC_SCREENHEIGHT * 0.5);
    view1.center = self.pointD;
    CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkAction)];
    [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    self.displayLink = displayLink;
} completion:^(BOOL finished) {
    [self.displayLink setPaused:YES];
    self.displayLink = nil;
    [self.view addSubview:self.tableView];
}];

}

-(void)displayLinkAction{

  //重要:只在动画运行时访问呈现树中的对象。当动画在进行中,呈现树就包含了图层显示在屏幕上的那一刻的值。该行为与图层树不同,图层树永远只表示最终的目标值。
//访问图层树中对象的presentationLayer属性将返回一个在呈现树中相对应的对象。你可能会通过该对象获取在动画执行过程中的某一时刻的属性值。
CALayer *presentLayer = self.view2.layer.presentationLayer;
NSLog(@"%@",NSStringFromCGPoint(presentLayer.position));

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(150, 0)];
[path addLineToPoint:CGPointMake(JC_SCREENWIDTH, 0)];
[path addLineToPoint:CGPointMake(JC_SCREENWIDTH, JC_SCREENHEIGHT)];
[path addLineToPoint:CGPointMake(150, JC_SCREENHEIGHT)];

[path addQuadCurveToPoint:CGPointMake(150, 0)
             controlPoint:presentLayer.position];

[path closePath];
self.shapeLayer.path = path.CGPath;

}


-(CAShapeLayer *)shapeLayer{
if (!_shapeLayer) {
    _shapeLayer = ({
        CAShapeLayer *shapLayer = [CAShapeLayer layer];
        shapLayer.fillColor = [UIColor magentaColor].CGColor;
        [self.view.layer addSublayer:shapLayer];
        shapLayer;
    });
}
return _shapeLayer;
}




@end
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 专业考题类型管理运行工作负责人一般作业考题内容选项A选项B选项C选项D选项E选项F正确答案 变电单选GYSZ本规程...
    小白兔去钓鱼阅读 9,069评论 0 13
  • Redis 数据备份与恢复 RedisSAVE命令用于创建当前数据库的备份。 备份数据 redis Save 命令...
    stakeing阅读 523评论 0 0
  • 《增长黑客》这本书有多火?我在简书上用该书名作为关键字搜了一下还真是有不少关于这本书的读书笔记或者是读后感之类的文...
    小7阅读 4,926评论 12 85
  • 一雨秋凉 秋阳绽开笑靥时 窗外却悬挂一帘濛濛烟雨 雨带来了深秋的微凉 落叶簌簌飘落 雨哪知秋的悲伤 我倾听着雨声 ...
    笔耕心田阅读 466评论 0 0