QQ20190215-161612-HD.gif
思路:
image.png
其中D點(diǎn)是可動(dòng)的, 其他點(diǎn)都是固定不變的, 哎. 其他思路感覺看代碼就可以了, 還是得增強(qiáng)語言溝通能力, 說不出來, 看代碼吧~??????, 應(yīng)該很好理解的
//
// 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{
//重要:只在動(dòng)畫運(yùn)行時(shí)訪問呈現(xiàn)樹中的對(duì)象停士。當(dāng)動(dòng)畫在進(jìn)行中,呈現(xiàn)樹就包含了圖層顯示在屏幕上的那一刻的值利凑。該行為與圖層樹不同卸勺,圖層樹永遠(yuǎn)只表示最終的目標(biāo)值砂沛。
//訪問圖層樹中對(duì)象的presentationLayer屬性將返回一個(gè)在呈現(xiàn)樹中相對(duì)應(yīng)的對(duì)象。你可能會(huì)通過該對(duì)象獲取在動(dòng)畫執(zhí)行過程中的某一時(shí)刻的屬性值曙求。
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