IOS视图交换实现实例

来源:互联网 发布:淘宝限时抢购在哪里 编辑:程序博客网 时间:2024/06/14 05:46

转载:http://blog.csdn.net/linux_zkf


IOS开发中经常会要求交换两个视图,下面给出简单的以交换两个图片的实例代码


- (void) swapButtonPressed: (id) sender

{

UIView *fron = [[self.view subviewsobjectAtIndex:2];

UIView *backt = [[self.view subviewsobjectAtIndex:1];

CGContextRef ctx = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:ctx];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationDuration:2.0];

front.alpha = 0.0f;

back.alpha = 1.0f;

front.transform = CGAffineTransformMakeScale(0.25f0.25f);

back.transform = CGAffineTransformIdentity;

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

[UIView setAnimationDelegate:self];

[UIView commitAnimations];

}


0 0
原创粉丝点击