作者:朱克锋
邮箱:zhukefeng@iboxpay.com
转载请注明出处:http://blog.csdn.net/linux_zkf
IOS开发中经常会看到淡进淡出的效果,其实现是用IOS的动画效果来实现的
下面给出简单实现的代码
- (void) fadeOut: (id) sender
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:ctx];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:2.0];
[[self.view viewWithTag:0x1024] setAlpha:0.0f];
[UIView commitAnimations];
}
- (void) fadeIn: (id) sender
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:ctx];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:2.0];
[[self.view viewWithTag:0x1024] setAlpha:1.0f];
[UIView commitAnimations];
}