码迷,mamicode.com
首页 > 其他好文 > 详细

淡出淡入

时间:2015-03-11 17:00:55      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //UIView
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(10, 100, 100, 200)];
    view.backgroundColor=[UIColor redColor];
    [self.view addSubview:view];
    
    //淡出
    //[self fadeOut:view];
    
    //淡入
    //[self fadeIn:view];
    
}

//淡出
-(void) fadeOut:(UIView *)view
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3];
    [view setAlpha:0.0f];
    [UIView commitAnimations];
}

//淡入
-(void) fadeIn:(UIView *)view
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3];
    [view setAlpha:1.0f];
    [UIView commitAnimations];
}

 

淡出淡入

标签:

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4329991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!