IT虾米网

iOS视图淡入淡出效果详解

xmjava 2018年06月23日 手机开发 457 0
- (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

发布评论

分享到:

IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

iOS几行代码让界面变圆角详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。