//
//  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. ES6嵌套对象的解构

    有下列对象需要解构: const obj:any[] = [ { id: 33, username: "mengsongna", realName: "孟松娜" ...

  2. Docker_简介(1)

    Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到任何流行的 ...

  3. Jenkins_忘记管理员密码的处理方法

    1.查看jenkins配置存放目录 2.修改config.xml的useSecurity的true为flase 3.重启jenkins服务 4.进入jenkins,不输入密码直接就进入了jenkins ...

  4. PowerShell【Do While、Do Until篇】

    1 $num=0 2 while($num -le 10) 3 { 4 $num 5 $num+=1 6 } 1 $num=0 2 do 3 { 4 $num 5 $num+=1 6 } 7 whil ...

  5. react中异步组件以及withRouter的使用

    什么是异步组件?简单来说就是异步加载一个组件,正常情况浏览器加载的是我们打包好的bundle.js文件,那么这个文件是集合了所有js是代码,然而我们首屏加载并不需要一次性加载所有的组件,这会造成性能的 ...

  6. HDU分拆素数和

    https://acm.hdu.edu.cn/showproblem.php?pid=2098 时间复杂度 #include<bits/stdc++.h> using namespace ...

  7. HDU 1576 A/B (两种解法)

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 分析:等式枚举法,由题意可得:, ,代入 ,    得:,把变量 合在一起得: :即满足 为 倍 ...

  8. c++中构造函数与析构函数

    构造函数与析构函数 构造函数与析构函数1. 构造函数2. 析构函数3. 拷贝函数4. 总结 在c++中有2个特殊的函数:构造函数和析构函数,它们分别对类对象进行初始化和清理工作. 1. 构造函数 构造 ...

  9. mysql5.7安装和卸载过程

    安装mysql 5.7 点击下面链接下载 mysql-5.7.27-winx64.zip 压缩文件 链接:https://pan.baidu.com/s/1CF5mmKkZkD_hxsjFOQJrzw ...

  10. 热词cloud-EChart安装

    1.安装npm install echarts npm install echarts-wordcloud注意版本:echarts版本5只能和wordcloud版本2的一起使用 :echarts版本4 ...