iOS掉落回弹效果
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS掉落回弹效果相关的知识,希望对你有一定的参考价值。
// // HomePageViewController.m // ParkingProject // // Created by Eric on 16/10/13. // Copyright © 2016年 Eric. All rights reserved. // #import "HomePageViewController.h" @interface HomePageViewController () @property(nonatomic,strong)UIButton *naviButton; @end @implementation HomePageViewController -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.naviButton.hidden = YES; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self handleCASpringAnimation]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.naviButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.naviButton.frame = CGRectMake(kDeviceWidth/2-10,200, 80, 20); [self.naviButton setTitle:@"动画" forState:UIControlStateNormal]; [self.naviButton setBackgroundColor:[UIColor orangeColor]]; [self.view addSubview:self.naviButton]; } -(void)handleCASpringAnimation{ CGRect screen = [UIScreen mainScreen].bounds; CATransform3D move = CATransform3DIdentity; CGFloat initAlertViewYPosition = (CGRectGetHeight(screen) + CGRectGetHeight(_naviButton.frame)) / 2; move = CATransform3DMakeTranslation(0, -initAlertViewYPosition, 0); move = CATransform3DRotate(move, 40 * M_PI/180, 0, 0, 1.0f); _naviButton.layer.transform = move; [UIView animateWithDuration:1.0f delay:0.0f usingSpringWithDamping:0.4f initialSpringVelocity:0.0f options:UIViewAnimationOptionCurveLinear animations:^{ self.naviButton.hidden = NO; CATransform3D init = CATransform3DIdentity; _naviButton.layer.transform = init; } completion:^(BOOL finished) { }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ [self handleCASpringAnimation]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end
关键代码如上.
以上是关于iOS掉落回弹效果的主要内容,如果未能解决你的问题,请参考以下文章
IOS端小程序橡皮筋回弹效果解决方案及坑总结(uni-swipe-action在IOS端的坑)
IOS端小程序橡皮筋回弹效果解决方案及坑总结(uni-swipe-actiond在IOS端的坑)