Mein Problem ist, dass ich 2 Grafikanimationen nacheinander habe, aber sie sind zusammen gemacht. Ich dachte, eine Methode mit Completion-Block zu schreiben, aber oder ich mache etwas falsch, oder es gibt einen anderen Weg, dies zu tun.Completion Block für Grafikanimation
Die Animation ist eine Ansicht, die sich aus dem Bildschirm (closeView) und der Standardanimation des Schließens des Viewcontrollers bewegt. Ich möchte den Viewcontroller geschlossen, wenn über die Animation der Ansicht ist.
Das ist, was ich
- (void)closeViewWithCompletion:(void (^) (BOOL finish))handler {
[self closeView];
handler(YES);
}
-(void) closeView{
[self.myview setFrame:CGRectMake(
-self.myview.frame.size.width
, self.myview.frame.origin.y
, self.myview.frame.size.width
, self.view.frame.size.height
)];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setDuration:.50];
[animation setDelegate:self];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
CALayer *layer = [self.myview layer];
[layer addAnimation:animation forKey:nil];
[UIView animateWithDuration:0.5 animations:^{
[greyMask setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0]];
} completion:^(BOOL finished) {
[greyMask removeFromSuperview];
}];
}
Gebrauch gemacht habe:
[vc closeViewWithCompletion:^(BOOL finish) {
[navController popViewControllerAnimated:true];
}
];
zeigen Sie beide der Animationscode, die Sie einzeln nacheinander ausführen müssen. – vaibhav