zoukankan      html  css  js  c++  java
  • push自定义动画

    //
    //  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
  • 相关阅读:
    Vue项目中全局过滤器的使用(格式化时间)
    vue-photo-preview 图片放大功能
    mongoimport导入json文件
    node后台,MongoDB作为数据库,vue前端获取数据并渲染
    JeasyUI,导出Excel
    EasyUI的textbox的disable ,readonly 用法
    EasyUI 中 Combobox里的onChange和onSelect事件的区别
    NullReferenceException 的可恨之处
    最新国家行政区划代码,来自国家统计局2018年底最新数据
    把旧系统迁移到.Net Core 2.0 日记 (20) --使用MiniProfiler for .NET
  • 原文地址:https://www.cnblogs.com/wangjuneng/p/4546914.html
Copyright © 2011-2022 走看看