View切换效果

视图翻转切换效果


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

@implementation FlipView

- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {

    // Start Animation Block

    CGContextRef context = UIGraphicsGetCurrentContext();

    [UIView beginAnimations:nil context:context];

    [UIView setAnimationTransition:

        UIViewAnimationTransitionFlipFromLeft

        forView:[self superview] cache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationDuration:1.0];

    // Animations

    [[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    // Commit Animation Block

    [UIView commitAnimations];

}

@end

视图翻页过渡效果


1

2

3

4

5

6

7

8

9

10

11

12

CGContextRef context = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationDuration:1.0];

// Apply the animation to the backdrop

[UIView setAnimationTransition:

    UIViewAnimationTransitionCurlUp

    forView:myView cache:YES];

// Exchange the two foreground views

[myView exchangeSubviewAtIndex:0

    withSubviewAtIndex:1];

[UIView commitAnimations];

视图淡入淡出效果


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

- (void) fadeOut: (id) sender {

    CGContextRef context = UIGraphicsGetCurrentContext();

    [UIView beginAnimations:nil context:context];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationDuration:1.0];

    [[self.view viewWithTag:999] setAlpha:0.0f];

    [UIView commitAnimations];

    self.navigationItem.rightBarButtonItem = BARBUTTON(@”Fade In”,@selector(fadeIn:));

}

- (void) fadeIn: (id) sender {

    CGContextRef context = UIGraphicsGetCurrentContext();

    [UIView beginAnimations:nil context:context];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationDuration:1.0];

    [[self.view viewWithTag:999] setAlpha:1.0f];

    [UIView commitAnimations];

    self.navigationItem.rightBarButtonItem = BARBUTTON(@”Fade Out”,@selector(fadeOut:));

}

- (void) viewDidLoad {

    self.navigationItem.rightBarButtonItem = BARBUTTON(@”Fade Out”,@selector(fadeOut:));

}

@end

让视图慢慢消失的效果

在调用 removeFromSuperview 的时候,当前视图会突然消失,这样显得很不友好。这段代码能够让视图慢慢消失。


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

//

//  UIView+JTRemoveAnimated.h

//

//  Created by james on 9/1/11.

//  http://ioscodesnippet.tumblr.com/

//

@interface UIView (JTRemoveAnimated)

- (void)removeFromSuperviewAnimated;

@end

//

//  UIView+JTRemoveAnimated.m

//

//  Created by james on 9/1/11.

//  http://ioscodesnippet.tumblr.com/

//

#import <QuartzCore/QuartzCore.h>

@implementation UIView (JTRemoveAnimated)

// remove static analyser warnings

#ifndef __clang_analyzer__

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    if ([animationID isEqualToString:@"fadeout"]) {

        // Restore the opacity

        CGFloat originalOpacity = [(NSNumber *)context floatValue];

        self.layer.opacity = originalOpacity;

        [self removeFromSuperview];

        [(NSNumber *)context release];

    }

}

- (void)removeFromSuperviewAnimated {

    [UIView beginAnimations:@"fadeout" context:[[NSNumber numberWithFloat:self.layer.opacity] retain]];

    [UIView setAnimationDuration:0.3];

    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

    [UIView setAnimationDelegate:self];

    self.layer.opacity = 0;

    [UIView commitAnimations];

}

#endif

@end

使用 Core Animation 制作视图过渡动画


1

2

3

4

5

6

7

8

9

10

11

CATransition *animation = [CATransition animation];

animation.delegate = self;

animation.duration = 1.0f;

animation.timingFunction = UIViewAnimationCurveEaseInOut;

animation.type = kCATransitionMoveIn;

animation.subtype = kCATransitionFromTop;

// Perform some kind of view exchange or removal here, for example

[myView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

[myView.layer addAnimation:animation forKey:@"move in"];

View切换效果

时间: 2024-10-28 16:43:13

View切换效果的相关文章

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

iOS7之定制View Controller切换效果

在iOS5和iOS6前,View Controller的切换主要有4种: 1. Push/Pop,NavigationViewController常干的事儿 2. Tab,TabViewController点击 3. Present Modal,调用ViewController的presentViewController:animated:completion:方法 4. Add ChildViewController,调用- (void)addChildViewController:(UIVi

Android学习笔记(25):带动画效果的View切换ViewAnimator及其子类

ViewAnimator可以实现带动画效果的View切换,其派生的子类是一些带动画效果切换功能的组件. ViewAnimator支持的XML属性: Attribute Name Description android:animateFirstView 设置显示第一个View组件时是否使用动画 android:inAnimation 设置显示组件时使用的动画 android:outAnimation 设置隐藏组件时使用的动画 1. ViewSwitcher视图切换组件. 添加视图的方法: 由Vie

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

用Fragment实现Tab页面切换效果初步总结

前言: 最近在Android项目中需要在活动中实现多页面切换的功能,第一次是实现的过程中,是让Activity同时去加载三个界面的,通过点击tab按钮对页面设置隐藏和显示,实现页面切换效果,但是后面发现这种实现方式其实存在很多问题: 首先,同时去加载三个页面,切换Activity的速度会变慢,尤其是布局中如果有很多ImageView,ImageButton等使用到图片资源的控件时,切换效果非常不好: 其次,由于使用了很多图片资源,在退出Activity的时候,像Drawable,Bitmap等一

UIVIewController自定义切换效果-b

之前介绍动画时提过UIView的转场动画,但是开发中我们碰到更多的viewController的切换,ios中常见的viewcontroller切换有四种:模态视图,导航栏控制器,UITabBarController以及addchildviewcontroller,自定义viewcontroller动画切换也是ios7中的新特性,这里整理下常见的操作,outline如下(本文参考http://onevcat.com/2013/10/vc-transition-in-ios7/,代码下载地址为ht

jQuery手机端触摸卡片切换效果

效果:http://hovertree.com/code/run/jquery/a1gr3gm9.html 可以用手机查看效果. 代码如下: 1 <!doctype html> 2 <html lang="zh"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=ed

Android 自定义 ViewPager 打造千变万化的图片切换效果

Android 自定义 ViewPager 打造千变万化的图片切换效果 标签: Android自定义ViewPagerJazzyViewPager 目录(?)[+] 转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38026503 记 得第一次见到ViewPager这个控件,瞬间爱不释手,做东西的主界面通通ViewPager,以及图片切换也抛弃了ImageSwitch之类的,开 始让ViewPager来做.时间长了,ViewPa

UIVIewController自定义切换效果

之前介绍动画时提过UIView的转场动画,但是开发中我们碰到更多的viewController的切换,ios中常见的viewcontroller切换有四种:模态视图,导航栏控制器,UITabBarController以及addchildviewcontroller,自定义viewcontroller动画切换也是ios7中的新特性,这里整理下常见的操作,outline如下(本文参考http://onevcat.com/2013/10/vc-transition-in-ios7/,代码下载地址为ht