切换view的动画

代码:

#import "MainViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIView *view1 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    view1.backgroundColor = [UIColor blueColor];

    UIView *view2 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    view2.backgroundColor = [UIColor yellowColor];

    [self.view addSubview:view1];
    [self.view addSubview:view2];
}

-(void) changeView
{
    NSLog(@"change view");
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:nil];
    [UIView commitAnimations];
}

-(void) changeView2
{
    CATransition *animation = [CATransition animation];
    [animation setDuration:1.25f];
    [animation setTimingFunction:[CAMediaTimingFunction
                                  functionWithName:kCAMediaTimingFunctionEaseIn]];
    [animation setType:kCATransitionReveal];
    [animation setSubtype: kCATransitionFromRight];
    [self.view.layer addAnimation:animation forKey:@"Reveal"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [CATransaction commit];
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self changeView];
}
@end
时间: 2024-08-24 19:51:33

切换view的动画的相关文章

动画切换view布局

动画切换view布局,可用于滚屏显示评论等例子 package com.example.animationviewdemo; import android.content.Context; import android.content.res.TypedArray; import android.os.Handler; import android.util.AttributeSet; import android.view.View; import android.view.animation

AndroidScreenSlide项目切换view动画效果

AndroidScreenSlide项目切换view动画效果 AndroidScreenSlide项目中有几个不错的效果,一:Card Flip翻页立体效果,二:Screen Slide 左右切换view时候和新加载view呈现效果,三:Layout Changes添加每一个item效果和删除每一个item效果.四:Advanced Screen Slide切换viewpager时页面切换动画效果.本项目来源:https://github.com/xiongwei-git/AndroidScre

swift 动画切换View心地层次顺序

1.动画效果 2.代码 // // AppDelegate.swift // AnimationDemo // // Created by 赵超 on 14-6-27. // Copyright (c) 2014年 赵超. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? //响应

AndroidScreenSlide项目切换view动画效果《IT蓝豹》

AndroidScreenSlide项目切换view动画效果 AndroidScreenSlide项目中有几个不错的效果,一:Card Flip翻页立体效果,二:Screen Slide 左右切换view时候和新加载view呈现效果,三:Layout Changes添加每一个item效果和删除每一个item效果.四:Advanced Screen Slide切换viewpager时页面切换动画效果.本项目来源:https://github.com/xiongwei-git/AndroidScre

jQuery演示10种不同的切换图片列表动画效果

经常用到的图片插件演示jQuery十种不同的切换图片列表动画效果 在线演示 下载地址 实例代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 <!DOCTYPE html> <html lang="en" class="no-

cocos2dx 常见的32种切换场景的动画

// TransitionJumpZoom// 作用: 创建一个跳动的过渡动画//    参数1:过渡动作的时间//    参数2:切换到目标场景的对象//    auto action = TransitionJumpZoom ::create(time , scene);// Director::getInstance()->replaceScene(action); // TransitionProgressRadialCCW//    作用: 创建一个扇形条形式的过渡动画, 逆时针方向/

cocos2dx切换播放的动画

美术资源一共有两段动画的序列帧,一个是手绘马行走图,一个是分子人行走图. 程序要实现的目的就是在同一个位置,点击按钮可以实现2段动画的切换. 因为动画最终是通过sprite的runAction执行的,所以我做了一个封装,返回一个带动画的精灵. CCSprite* HelloWorld::createAnimateSprite( int start, int end, CCString* startFrame, CCString* formatStr) { CCSize visibleSize =

Android自定义Viewgroup切换View带有吸附效果

1.概述 先上效果图 大概就是这个效果,先说说实现思路 1.首先我们要拿到图片的url(网络)或id.路径(本地),将View与数据进行绑定,写我们自己的Adapter 2.自定义Viewgroup将要显示的view进行布局,以及处理触摸事件进行逻辑处理 3.写切换回调 2.实现 1)自定义Adapter 这里我下载的网络图片,同样可以将图片放到res下设置ImageView的内容 public class DragPageViewAdapter { private static final S

如果写一个点击view带动画的下滑展开显示隐藏内容的控件

原理是在onMeasure中得到隐藏内容的高度,点击这个view的时候对隐藏的view startAnimation,让它的高度从0增长到onMeasure得到的这个View的measureHeight 具体这样写: public class ExpandableLayout extends LinearLayout { private Context mContext; private LinearLayout mHandleView; private RelativeLayout mCont