zoukankan      html  css  js  c++  java
  • 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

    关键代码如上.

  • 相关阅读:
    uva 10099(最大生成树+搜索)
    Codeforces Round #218 (Div. 2) 解题报告
    CodeChef December Challenge 2013 解题报告
    Codeforces Round #217 (Div. 2) 解题报告
    uva 1423 (拓扑排序)
    UESTC 1307 windy数(数位DP)
    Codeforces Round #216 (Div. 2) 解题报告
    Codeforces Round #215 (Div. 2) 解题报告
    uva 10047(BFS)
    uva 10369(最小生成树)
  • 原文地址:https://www.cnblogs.com/sunmair/p/5957534.html
Copyright © 2011-2022 走看看