博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS掉落回弹效果
阅读量:6955 次
发布时间:2019-06-27

本文共 2534 字,大约阅读时间需要 8 分钟。

////  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
*)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

关键代码如上.

转载于:https://www.cnblogs.com/sunmair/p/5957534.html

你可能感兴趣的文章
Oracle DB优化-如何看SQL的执行计划+收集表的统计信息
查看>>
深度学习基础系列(六)| 权重初始化的选择
查看>>
angular4 跨域携带cookie的设置
查看>>
蓝桥杯第五届JavaC组杨辉三角问题解决方法
查看>>
定制自己的数据类型
查看>>
CSS样式表初始化杂谈
查看>>
[转]winform控件webbrowser和js脚本互调
查看>>
Selenium WebDriver控制操作(Python)
查看>>
最短路 - spfa
查看>>
java 一些容易忽视的小点-类和对象
查看>>
weblogic安装升级配置
查看>>
在Spring MVC中使用FileUpload功能
查看>>
[转] Windows Server 2012 Beta (Hyper-V 3.0) VM Replica與Live Migration Winout Shared Storage
查看>>
枚举 enum
查看>>
JavaScript 学习笔记
查看>>
C# 文件读写系列三
查看>>
让Android的输入框与文本框带滚动条ScrollView
查看>>
基于jQuery或Zepto实现实时监控用户浏览信息
查看>>
【高德地图API】如何打造十月妈咪品牌地图?
查看>>
laravel Ajax请求 X-CSRF验证问题
查看>>