diesen Code Versuchen:
- (IBAction)btnExit:(id)sender {
[self setFrame:CGRectMake(-self.frame.size.width
,200
,self.frame.size.width
, self.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 layer];
[layer addAnimation:animation forKey:nil];
}
- (IBAction)btnEnter:(id)sender {
[self setFrame:CGRectMake(10
,200
,self.frame.size.width
, self.frame.size.height
)];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setDuration:.50];
[animation setDelegate:self];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
CALayer *layer = [self layer];
[layer addAnimation:animation forKey:nil];
}
Mit diesem einfachen Code, den ich bewegen (mit btnEnter
) myView
innerhalb des Bildschirms (at beginnen aus dem Bildschirm ist) mit eine Animation und (btnExit
) mit einer anderen Animation ausziehen.
Sie können viele Animationen verwenden, ich wählte eine.
Denken Sie daran, CAAnimationDelegate
bei Ihrer Klassendefinition hinzuzufügen.
Der Hintergrund ist immer gleich. (UIViewController Ansicht)
Mögliche Duplikat animieren [UINavigationController - Halten Hintergrundbild über alle Ansichten hinweg] (http://stackoverflow.com/questions/13095968/uinavigationcontroller-keep-background-image-über-alle-views – Roy