IT虾米网

iOS视图淡入淡出效果

xmjava 2018年06月23日 手机开发 1174 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几行代码让界面变圆角