zoukankan      html  css  js  c++  java
  • transitionFromView方法的使用

    transitionFromView方法的使用

    效果

    源码

    //
    //  ViewController.m
    //  TransitionFromView
    //
    //  Created by YouXianMing on 16/5/30.
    //  Copyright © 2016年 YouXianMing. All rights reserved.
    //
    
    #import "ViewController.h"
    
    typedef enum : NSUInteger {
        
        kBottomView = 1000,
        kTopView,
        
    } EViewControllerTag;
    
    @interface ViewController () {
    
        UIView *redView;
        UIView *yellowView;
        UIView *containerView;
    }
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        
        [super viewDidLoad];
        
        // ContainerView
        containerView         = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 350)];
        containerView.center  = self.view.center;
        [self.view addSubview:containerView];
        
        // BottomView
        redView                 = [[UIView alloc] initWithFrame:containerView.bounds];
        redView.tag             = kBottomView;
        redView.backgroundColor = [UIColor redColor];
        [containerView addSubview:redView];
        
        // TopView
        yellowView                 = [[UIView alloc] initWithFrame:containerView.bounds];
        yellowView.tag             = kTopView;
        yellowView.backgroundColor = [UIColor yellowColor];
        [containerView addSubview:yellowView];
        
        // Button
        UIButton *button = [[UIButton alloc] initWithFrame:self.view.bounds];
        [button addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
    
    - (void)buttonEvent:(UIButton *)button {
        
        button.enabled = NO;
        
        [UIView transitionFromView:[containerView viewWithTag:kTopView]
                            toView:[containerView viewWithTag:kBottomView]
                          duration:0.5f
                           options:UIViewAnimationOptionTransitionFlipFromLeft
                        completion:^(BOOL finished) {
                            
                            button.enabled = YES;
                            
                            if ([[containerView viewWithTag:kBottomView] isEqual:redView]) {
                                
                                [containerView insertSubview:yellowView belowSubview:redView];
                                redView.tag    = kTopView;
                                yellowView.tag = kBottomView;
                                
                            } else {
                            
                                [containerView insertSubview:redView belowSubview:yellowView];
                                redView.tag    = kBottomView;
                                yellowView.tag = kTopView;
                            }
                        }];
    }
    
    @end

    细节

  • 相关阅读:
    原子变量AtomicInteger
    8.2.2.2 Speed of UPDATE Statements 加速UPDATE语句:
    8.2.2 Optimizing DML Statements 优化DML 语句:
    CSS3中-moz、-ms、-webkit和-o分别代表什么意思
    8.2.1.19 Optimizing LIMIT Queries 优化LIMIT 查询:
    java.lang.IllegalArgumentException: Negative time
    8.2.1.17 DISTINCT Optimization
    Python基本语法_函数_参数的多类型传值
    Python基本语法_函数_参数的多类型传值
    8.2.1.16 GROUP BY Optimization
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/5542634.html
Copyright © 2011-2022 走看看