@interface ViewController ()
@property(nonatomic,retain)UIView *redview;
@property(nonatomic,retain)UIView *yellowview;
@end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad]; self.redview=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
self.redview.backgroundColor=[UIColor redColor];
[self.view addSubview:self.redview];
[self.redview release];
self.yellowview=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
_yellowview.backgroundColor=[UIColor yellowColor];
[self.view addSubview:_yellowview];
//[_yellowview release];
} -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ //转场动画,切换两个view 注意:如果要切换两个viewcontroller做转场要找到共同view;
UIView *fromvalue=nil;
UIView *tovalue=nil;
if(_yellowview.superview){
fromvalue=_yellowview;
tovalue=_redview;
}
else{
fromvalue=_redview;
tovalue=_yellowview; } [UIView transitionFromView:fromvalue toView:tovalue duration:0.5 options:UIViewAnimationOptionTransitionFlipFromBottom completion:^(BOOL finished) {
//这个api 原理 :
// 1:[fromvalue.superview addSubview:tovalue];
// 2:[fromvalue removeFromSuperview];
NSLog(@"fromvalue-->%@",fromvalue.superview);
NSLog(@"tovalue-->%@",tovalue.superview);
}];
}

ios中两个view动画切换的更多相关文章

  1. IOS中两个view的切换

    在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secon ...

  2. IOS—通过ChildViewController实现view的切换

    IOS-通过ChildViewController实现view的切换 在以前,一个UIViewController的View可能有很多小的子view.这些子view很多时候被盖在最后,我们在最外层Vi ...

  3. 小记:iOS 中一般对于 view 不依赖 model 的的两种代码书写形式

    一. 前言 对于在 MVC 的定义中,view 层是不引用 model 层,view 和 model 是不相往来的 一般开发中,我们都写过 在自定义 view 中增加一个 model 的属性,外接直接 ...

  4. iOS:iOS中的几种动画

    本文来自收藏,感谢原创博主. iOS中的动画 摘要 本文主要介绍核iOS中的动画:核心动画Core Animation, UIView动画, Block动画, UIImageView的帧动画. 核心动 ...

  5. [转]IOS Segment页面之间view的切换

    有三个view,分别为view1.view2.view3,通过UISegmentedControl进行三个view的切换. @interface UIViewDemoViewController :  ...

  6. IOS中封装一个View的思路

    一.封装一个View的思路 1.将View内部的业务逻辑(显示内容)封装到View中 2.一般情况下,View的位置应该由父控件来决定,也就是位置不应该固定死在View内部 3.至于View的宽高,根 ...

  7. objective-C 中两种实现动画的方法

    第一种方法: [UIView beginAnimations:@"Curl"context:nil];//动画开始 [UIView setAnimationDuration:1.2 ...

  8. objective-C 中两种实现动画的方法(转)

     转发自:http://wayne173.iteye.com/blog/1250232 第一种方法: [UIView beginAnimations:@"Curl"context: ...

  9. iOS中的隐式动画

    隐式动画就是指  在 非 人为在代码中 定义动画  而系统却默认  自带   的动画  叫做隐式动画. 比如  改变 图层  的颜色  位置  和   透明度  的时候    都会  产生附带的渐变的 ...

随机推荐

  1. Asp.net WebAPi gzip压缩和json格式化

    现在webapi越来越流行了,很多时候它都用来做接口返回json格式的数据,webapi原本是根据客户端的类型动态序列化为json和xml的,但实际很多时候我们都是序列化为json的,所以webapi ...

  2. [leetcode]Spiral Matrix II @ Python

    原题地址:https://oj.leetcode.com/problems/spiral-matrix-ii/ 题意: Given an integer n, generate a square ma ...

  3. diy作品——视觉追踪小车介绍

    最近刚刚完毕了一个追踪功能的小车.大体功能例如以下:小车能通过网线给电脑传图(抱歉.临时没搞wifi驱动).并在电脑端通过鼠标选中待跟踪的目标,然后小车就開始追踪.由于追踪框有缩放功能.所以也能推断物 ...

  4. Android -- Handling back button press Inside Fragments

    干货(1) 首先创建一个抽象类BackHandledFragment,该类有一个抽象方法onBackPressed(),所有BackHandledFragment的子类在onBackPressed方法 ...

  5. 【Spark】SparkStreaming-foreachrdd foreachpartition

    SparkStreaming-foreachrdd foreachpartition foreachrdd foreachpartition_百度搜索 SparkStreaming之foreachRD ...

  6. z-index的堆叠规则

    原文: https://www.cnblogs.com/starof/p/4424926.html 对于所有定位,最后都不免遇到两个元素试图放在同一位置上的情况.显然,其中一个必须盖住另一个.但,如何 ...

  7. Struts2的Action继承ActionSupport时,利用AOP来拦截Action出现NoSuchMethodException

    参考:http://zhanghua.1199.blog.163.com/blog/static/46449807201111139501298/ 做项目的时候,由于要用到在Struts2的Actio ...

  8. [Algorithm] How many times is a sorted array rotated?

    Given a sorted array, for example: // [2,5,6,8,11,12,15,18] Then we rotated it 1 time, it becomes: / ...

  9. 【Nodejs】使用http.request批量下载MP3,发现网络文件大于1000K时下载文件为0K

    这又一次让我对http.request产生质疑 //====================================================== // 喜爱123四年级上英语MP3下载 ...

  10. Wifidog初分析

    一.综述 wifidog是搭建无线热点认证系统的解决方案之一,他比nocat.nodog更适合互联网营销思路.常见的使用在openwrt系统上,它实现了路由器和认证服务器的数据交互,在路由器方(客户端 ...