iPhone 淡入淡出动画

    //

//  TestBedViewControl_002.m

//  UIViewAnimationsTest

//

//  Created by mir on 11-4-1.

//  Copyright 2011 __MyCompanyName__. All rights reserved.

//

 

#import "TestBedViewControler_002.h"

 

 

@implementation TestBedViewControler_002

 

/*

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

        // Custom initialization

    }

    return self;

}

*/

 

/*

// Implement loadView to create a view hierarchy programmatically, without using a nib.

- (void)loadView {

}

*/

 

-(void) animationFinished:(id) sender{

self.navigationItem.rightBarButtonItem=BARBUTTON(@"Swap",@selector(swap:));

}

 

-(void) swap:(id) sender{

self.navigationItem.rightBarButtonItem=nil;

UIView *frontObject=[[self.view subviews] objectAtIndex:1];

UIView *backObject=[[self.view subviews] objectAtIndex:0];

CGContextRef context=UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationDuration:1.0f];

frontObject.alpha=0.0f;

backObject.alpha=1.0f;

frontObject.transform=CGAffineTransformMakeScale(0.25f, 0.25f);

backObject.transform=CGAffineTransformIdentity;

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

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(animationFinished:)];

[UIView commitAnimations];

}

 

 

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

    [super viewDidLoad];

self.navigationItem.rightBarButtonItem=BARBUTTON(@"Swap",@selector(swap:));

UIImageView *view1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];

view1.tag=998;

UIImageView *view2=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];

view2.tag=999;

[self.view addSubview:view1];

[self.view addSubview:view2];

[view1 release];

[view2 release];

UIView *backObject=[self.view viewWithTag:998];

backObject.transform=CGAffineTransformMakeScale(0.25f, 0.25f);

backObject.alpha=0.0f;

}

 

 

/*

// Override to allow orientations other than the default portrait orientation.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    // Return YES for supported orientations

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

*/

 

- (void)didReceiveMemoryWarning {

    // Releases the view if it doesn't have a superview.

    [super didReceiveMemoryWarning];

 

    // Release any cached data, images, etc that aren't in use.

}

 

- (void)viewDidUnload {

    [super viewDidUnload];

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

}

 

 

- (void)dealloc {

    [super dealloc];

}

 

 

@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值