//
//  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. Qos 0/1/2的理解

    Qos 0/1/2的理解 Qos 0 最多一次的传输 消息是基于TCP/IP网络传输的.没有回应,在协议中也没有定义重传的语义.消息可能到达服务器1次,也可能根本不会到达. Qos 1 至少一次的传输 ...

  2. Tcpdump抓包命令使用

    tcpdump命令需要使用root执行 1. 查看网卡命令 ifconfig 2. 监视编址到指定端口的TCP或UDP数据包,那么执行以下命令: tcpdump -i eth0 host 10.43. ...

  3. mysql在Linux下大小写敏感设置

    默认情况下,mysql在windows下是不区分大小写的,但是mysql在linux下大小写规则是这样的: 1.数据库名与表名是严格区分大小写的: 2.表的别名是严格区分大小写的: 3.列名与列的别名 ...

  4. Google面试评分卡

    Google对工程面试之前,会让面试人员填一张评分卡,以加强面试官对你的理解,大致内容如下: 0 - 对于相关技术领域还不熟悉. 1 - 可以读懂这个领域的基础知识. 2 - 可以实现一些小的改动,清 ...

  5. python appium使用uiselector定位时,提示 Could not parse UiSelector argument: 'XXX' is not a string

    运行自动化代码,appium返回Could not parse UiSelector argument: 'XXX' is not a string,其中的xxx就是定位的元素 解决方案:外侧用 '' ...

  6. Elasticsearch打造全文搜索引擎(一)

     带着问题上路--ES是如何产生的? (1)思考:大规模数据如何检索? 如:当系统数据量上了10亿.100亿条的时候,我们在做系统架构的时候通常会从以下角度去考虑问题: 1)用什么数据库好?(mysq ...

  7. Word文档学习小练习链接

    1. < Word2010初学> https://www.toutiao.com/i6487370439910752782/ 2. <Word2010格式化可爱的家乡> htt ...

  8. 51 Nod 1183 编辑距离 (动态规划基础)

    原题链接:1183 编辑距离 题目分析:这个最少的操作次数,通常被称之为编辑距离."编辑距离"一次本身具有最短的意思在里面.因为题目有"最短"这样的关键词,首先 ...

  9. hadoop入门到实战(6)hive常用优化方法总结

    问题导读:1.如何理解列裁剪和分区裁剪?2.sort by代替order by优势在哪里?3.如何调整group by配置?4.如何优化SQL处理join数据倾斜?Hive作为大数据领域常用的数据仓库 ...

  10. 使用NSSM把任意exe程序注册成Windows服务

    1.登录NSSM官网下载最新版本: http://www.nssm.cc/download 2.解压之后可以看到win32和win64位的nssm.exe,根据自己的电脑选择使用 3.拷贝一份nssm ...