transitionFromView方法的使用

效果

源码

//
// ViewController.m
// TransitionFromView
//
// Created by YouXianMing on 16/5/30.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "ViewController.h" typedef enum : NSUInteger { kBottomView = ,
kTopView, } EViewControllerTag; @interface ViewController () { UIView *redView;
UIView *yellowView;
UIView *containerView;
} @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // ContainerView
containerView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
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

细节

transitionFromView方法的使用的更多相关文章

  1. UIView 的transitionFromView方法实现视图切换

    #import "ViewController.h" @interface ViewController () @property (strong, nonatomic) IBOu ...

  2. iOS UIKit:animation

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  3. javaSE27天复习总结

    JAVA学习总结    2 第一天    2 1:计算机概述(了解)    2 (1)计算机    2 (2)计算机硬件    2 (3)计算机软件    2 (4)软件开发(理解)    2 (5) ...

  4. UIView属性及方法

    @property(nonatomic) CGFloat alpha //设置视图的透明度 //透明度的设置从最小0.0到1.0 ,1.0为完全不透明, //其中这个属性只影响当前视图,并不会影响其子 ...

  5. iOS开发UUIView动画方法总结

    #动画设置 UIView动画实现 @interface ViewController () @property (weak, nonatomic) IBOutlet UIView *myView; @ ...

  6. UIView封装动画--iOS利用系统提供方法来做转场动画

    UIView封装动画--iOS利用系统提供方法来做转场动画 UIViewAnimationOptions option; if (isNext) { option=UIViewAnimationOpt ...

  7. mapreduce多文件输出的两方法

    mapreduce多文件输出的两方法   package duogemap;   import java.io.IOException;   import org.apache.hadoop.conf ...

  8. 【.net 深呼吸】细说CodeDom(6):方法参数

    本文老周就给大伙伴们介绍一下方法参数代码的生成. 在开始之前,先补充一下上一篇烂文的内容.在上一篇文章中,老周检讨了 MemberAttributes 枚举的用法,老周此前误以为该枚举不能进行按位操作 ...

  9. IE6、7下html标签间存在空白符,导致渲染后占用多余空白位置的原因及解决方法

    直接上图:原因:该div包含的内容是靠后台进行print操作,输出的.如果没有输出任何内容,浏览器会默认给该空白区域添加空白符.在IE6.7下,浏览器解析渲染时,会认为空白符也是占位置的,默认其具有字 ...

随机推荐

  1. Mysql介绍,与将脚本导入新数据库

    一:介绍 1.介绍 Mysql是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Database Management System:关系数据库管理系 ...

  2. 关于伪类“:pseudo-class”和伪元素“::pseudo-element”的常见应用

    伪类用于指定要选择的元素的特殊状态,向其添加特殊的效果,比如: input { width: 515px; height: 50px; padding: 10px 20px; border: 1px ...

  3. 002.LVM创建

    一 LVM创建步骤 创建分区 创建PV 创建VG 创建LV 格式化及挂载 二 创建分区 使用分区工具(如fdisk等)创建LVM分区,却将分区标识为LVM的分区类型8e. [root@kauai ~] ...

  4. Javascript数据类型转换规则

    前言 Javascript有7种数据类型,包括5种原始类型(也叫原始值)number.Boolean.string.null.undefined和2种复合类型object.array,它们之间可以根据 ...

  5. codeforces-1080C

    title: codeforces-1080C date: 2018-11-25 14:23:53 tags: acm 刷题 categories: Codeforces https://www.cn ...

  6. 一个简单的日志函数C++

    有时候程序总是会发生意想不到的情况,为了方便排查错误的情况,还是写日志比较方便.这里自己写了一个简单的函数,能实现基本的功能. BOOL WriteLog(char * DataBuffer) { C ...

  7. html (第四本书第八章参考)

    上机1 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8 ...

  8. Linux __attribute__(("hidden"))、default

    记录下: Linux下导出so库接口时在下面情况下无法导出(编译时增加了__attribute__(("hidden"))属性). void * __attribute__((&q ...

  9. 在Asp.net core返回PushStream

    最近用asp.net core webapi实现了一个实时视频流的推送功能,在Asp.net中,这个是通过PushStreamContent来实现的. 基于对asp.net core的知识,随手写了一 ...

  10. [Deepin 15] 安装 Java 8、Git、Firefox、SafeEyes(定时提醒休息工具)

    一.安装 JDK 8 1.到官网,用 迅雷下载 安装包 (jdk-8u131-linux-x64.tar.gz) 2.解压放到目录 /opt/software/jdk 3.配置环境变量 sudo vi ...