//
//  ViewController.m
//  ViewControllerAnimation
//
//  Created by mac on 15/5/26.
//  Copyright (c) 2015年 BSY. All rights reserved.
//
 
#import "ViewController.h"
#import "TwoViewController.h"
@interface ViewController ()<UINavigationControllerDelegate,UIViewControllerTransitioningDelegate>
@property(nonatomic,strong)TwoViewController*two;
@property(nonatomic,strong)UIViewController *currentViewController;;
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
     
    self.title = @"第一页";
    self.view.backgroundColor = [UIColor grayColor];
    self.Animator = [[BSYAnimator alloc]init];
    self.TransitionAnimator = [[BSYTransitionAnimator alloc]init];
     
    UIButton *button  = [UIButton buttonWithType: UIButtonTypeCustom];
    [button setFrame:CGRectMake(100, 100, 100, 100)];
    [button setTitle:@"Push" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    TwoViewController *two = [[TwoViewController alloc]init];
    self.two = two;
    self.navigationController.delegate = self;
    two.transitioningDelegate = self;
    two.modalPresentationStyle = UIModalPresentationCustom;
     
    [self addChildViewController:two];
    self.currentViewController = two;
}
 
-(void)buttonClick
{
    [self.navigationController pushViewController:self.two animated:YES];
}
 
#pragma mark - UINavigationControllerDelegate iOS7新增的2个方法
// 动画特效
- (id<UIViewControllerAnimatedTransitioning>) navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
     
    if (operation == UINavigationControllerOperationPush) {
        return self.Animator;
    }else{
        return nil;
    }
}
#pragma mark - Transitioning Delegate (Modal)
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    self.TransitionAnimator.animationType = AnimationTypePresent;
    return self.TransitionAnimator;
}
 
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    self.TransitionAnimator.animationType = AnimationTypeDismiss;
    return self.TransitionAnimator;
}
 
@end

push自定义动画的更多相关文章

  1. iOS 8自定义动画转场上手指南

    原文:http://www.cocoachina.com/ios/20150126/11011.html iOS 5发布的时候,苹果针对应用程序界面的设计,提出了一种全新的,革命性的方法—Storyb ...

  2. android 自定义动画

    android自定义动画注意是继承Animation,重写里面的initialize和applyTransformation,在initialize方法做一些初始化的工作,在applyTransfor ...

  3. Android开发学习之路-RecyclerView的Item自定义动画及DefaultItemAnimator源码分析

    这是关于RecyclerView的第二篇,说的是如何自定义Item动画,但是请注意,本文不包含动画的具体实现方法,只是告诉大家如何去自定义动画,如何去参考源代码. 我们知道,RecyclerView默 ...

  4. 深入学习jQuery自定义动画

    × 目录 [1]属性对象 [2]可选参数 [3]选项参数 前面的话 很多情况下,前面介绍的jQuery动画的简单效果无法满足用户的各种需求,那么就需要对动画有更多的限制,需要采取一些高级的自定义动画来 ...

  5. 自定义动画css属性

    自定义动画: 1.animation-name(自定义动画名称) 元素所应用的动画名称,必须与@keyframes使用,名称由@keyframes定义. keyframes(动画关键帧):以@keyf ...

  6. [UE4]CustomAnimationBlueprintNode 自定义动画蓝图节点

    目的:在AnimationBlueprint中使用自定义动画控制节点. 主要过程: 1.      引用相关模块.在Client.Build.cs文件中,PublicDependencyModuleN ...

  7. CSS3初学篇章_6(自定义动画)

    自定义动画 由于有一部分低版本的浏览器并不支持的问题,所以这个样式要多做兼容,各大浏览器兼容前缀如下: 前缀 浏览器  -webkit  chrome和safari  -moz  firefox  - ...

  8. Popwindow自定义动画(nexus5不支持暂未解决)

    遇到一个问题,先记录一下 PopWindow自定义动画 import android.app.Activity; import android.graphics.drawable.BitmapDraw ...

  9. Android开发UI之自定义动画

    自定义动画,需要新建一个类,继承Animation类. 重写applyTransformation()方法和initialize()方法. applyTransformation(float inte ...

随机推荐

  1. emqx启用redis认证插件

    本次测试使用的是免费版的 emqx-windows-4.3.10 版本 1.修改redis插件 emqx_auth_redis.conf  设置用户名密码,    auth.redis.passwor ...

  2. C#中CancellationToken和CancellationTokenSource用法

    之前做开发时,一直没注意这个东西,做了.net core之后,发现CancellationToken用的越来越平凡了. 这也难怪,原来.net framework使用异步的不是很多,而.net cor ...

  3. spring-Ioc学习笔记

    spring 是面向Bean的编程 Ioc (Inversion of Control) 控制反转/依赖注入(DI:Dependency Injection) Aop(Aspect Oriented ...

  4. 第10组 Alpha冲刺 (5/6)

    1.1基本情况 ·队名:今晚不睡觉 ·组长博客:https://www.cnblogs.com/cpandbb/p/13996848.html ·作业博客:https://edu.cnblogs.co ...

  5. Python的内存管理和垃圾回收机制

    内存管理 Python解释器由c语言开发完成,py中所有的操作最终都由底层的c语言来实现并完成,所以想要了解底层内存管理需要结合python源码来进行解释. 1. 两个重要的结构体 include/o ...

  6. Java语言学习案例雷霆战机

    1.Java雷霆战机学习笔记(一)-资源加载 https://www.toutiao.com/i6631331313259381255/ 2.Java雷霆战机学习笔记(二)-音乐播放 https:// ...

  7. 论文翻译:2021_ICASSP 2021 ACOUSTIC ECHO CANCELLATION CHALLENGE: INTEGRATED ADAPTIVE ECHO CANCELLATION WITH TIME ALIGNMENT AND DEEP LEARNING-BASED RESIDUAL ECHO PLUS NOISE SUPPRESSION

    论文地址:https://ieeexplore.ieee.org/abstract/document/9414462 ICASSP 2021声学回声消除挑战:结合时间对准的自适应回声消除和基于深度学习 ...

  8. Nginx虚拟主机、日志排错、模块配置

    目录 Nginx虚拟主机 1. 基于多IP的方式 2. 基于多端口的方式 3. 基于多域名的方式 Nginx日志 Nginx配置文件配置项 Nginx模块 Nginx访问控制模块 Nginx状态监控模 ...

  9. Cesium中级教程4 - 空间数据可视化(二)

    Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coinidea.com/ Viewer中的Entity功能 让我们看看Viewer为操作e ...

  10. ssh代理转发

    实验环境 serverA:172.16.2.116 serverB:172.16.2.225 serverC:172.16.2.115 "代理转发"是针对ssh认证过程的一种转发 ...