你好,歡迎來到IOS教程網

 Ios教程網 >> IOS使用技巧 >> IOS技巧綜合 >> 淡出淡入

淡出淡入

編輯:IOS技巧綜合
[摘要]本文是對淡出淡入的講解,對學習IOS蘋果軟件開發有所幫助,與大家分享。
- (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];
}
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved