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

关键代码如上.

时间: 2024-12-21 04:09:41

iOS掉落回弹效果的相关文章

ios滑动回弹效果导致的穿透问题

1 给样式中去除掉下面的css样式 -webkit-overflow-scrolling:touch;/* 当手指从触摸屏上移开,会保持一段时间的滚动 */ -webkit-overflow-scrolling:auto;/* 当手指从触摸屏上移开,滚动会立即停止 */ 也就是: *{ -webkit-overflow-scrolling:auto !important; } 2 使用插件 方法二:可以使用插件inobounce(但是只适用于ios系统,安卓不适用) 官网:https://git

Android仿IOS回弹效果 ScrollView回弹 总结

Android仿IOS回弹效果  ScrollView回弹 总结 应项目中的需求  需要仿IOS 下拉回弹的效果 , 我在网上搜了很多 大多数都是拿scrollview 改吧改吧 试了一些  发现总有点小问题 下面的代码是我对大家发布的做了点小修改   觉得没太大问题 package com.example.myscrollview; import android.content.Context; import android.graphics.Rect; import android.util

-webkit-overflow-scrolling 与滚动回弹效果.

参考来源:https://developer.mozilla.org/zh-CN/docs/Web/CSS/-webkit-overflow-scrolling https://www.w3cways.com/1988.html -webkit-overflow-scrolling 用来控制元素在移动设备上是否使用滚动回弹效果. 事故の起因 要做有很多列表的页面,然后并不适用iscroll等滚动的插件,做完也没按之后,滑动列表卡顿卡顿的,遭啦,这样子的滑动太让人不舒服. 网上搜索了一下,发现了一

实现ios常见菜单效果的思路

目前见过的实现边侧菜单的效果,比较流行的有以下三种:(效果图) 1.菜单栏覆盖在部分主视图上 附上实现该效果的一个不错的源码地址: http://code4app.com/ios/RNFrostedSidebar/524399706803fa3c33000001 (1)最开始要实现这个效果,我想最简单的方式就是:添加UIView,加上一个self.view大小的子视图,菜单列表以外的区域设为透明灰色.后来发现,如果当前的控制器有显示导航栏或者工具栏,这个子视图就无法遮盖住导航栏或者工具栏上面的按

iOS的动画效果类型及实现方法

实现iOS漂亮的动画效果主要有两种方法, 一种是UIView层面的, 一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransition进行了封装,它只能用于一些简单的.常用的效果展现,这里写一个常用的示例代码,供大家参考. [UIView beginAnimations:@"Curl"context:nil];//动画开始 [UIView setAnimationDuration:0.75]; [UIView se

ios各种动画效果

ios各种动画效果 最普通动画: //开始动画 [UIView beginAnimations:nil context:nil];  //设定动画持续时间 [UIView setAnimationDuration:2]; //动画的内容 frame.origin.x += 150; [img setFrame:frame]; //动画结束 [UIView commitAnimations]; 连续动画:一个接一个地显示一系列的图像 NSArray *myImages = [NSArray arr

iOS星级评分效果实现

原文链接: iOS星级评分效果实现 简书主页:http://www.jianshu.com/users/37f2920f6848 Github主页:https://github.com/MajorLMJ iOS开发者公会-技术1群 QQ群号:87440292 iOS开发者公会-技术2群 QQ群号:232702419 iOS开发者公会-议事区   QQ群号:413102158

ScrollView的阻尼回弹效果实现(仿qq空间)

玩过新浪微博,qq空间等手机客户端的童鞋,都应该清楚,在主界面向下滑动时,会有一个阻尼回弹效果,看起来挺不错,接下来我们就来实现一下这种效果,下拉后回弹刷新界面,先看效果图: 这个是编辑器里面的界面效果,不言自明: 运行效果: 正常界面下: 下拉: 下拉结束: 实现代码: 主要部分就是重写的ScrollView: package com.byl.scollower; import android.content.Context; import android.graphics.Rect; imp

iOS文字滚动效果 之纵向滚动

原文链接: iOS文字滚动效果 之纵向滚动 简书主页:http://www.jianshu.com/users/37f2920f6848 Github主页:https://github.com/MajorLMJ iOS开发者公会-技术1群 QQ群号:87440292 iOS开发者公会-技术2群 QQ群号:232702419 iOS开发者公会-议事区   QQ群号:413102158