视图淡入淡出效果

- (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
//该片段来自于http://outofmemory.cn

manbetx手机网页版跳转代码

SearchViewController* searchVC = [[SearchViewControlleralloc]init];

CATransition*animation= [CATransitionanimation];

animation.timingFunction=UIViewAnimationCurveEaseInOut;

animation.type=@"Fade";

animation.duration=.3f;

animation.subtype=kCATransitionFromRight;

[[UIApplicationsharedApplication].keyWindow.layeraddAnimation:animationforKey:nil];

UINavigationController*nav = [[UINavigationControlleralloc]initWithRootViewController:searchVC];

[self.navigationControllerpresentViewController:navanimated:NOcompletion:nil];```
返回代码

__weaktypeof(self) weakSelf =self;

[UIViewanimateWithDuration:.3animations:^{

weakSelf.view.alpha=0;

}completion:^(BOOLfinished) {

[weakSelf.navigationControllerdismissViewControllerAnimated:NOcompletion:nil];

}];“`

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图