Hi guys I have 2 UIViews. First UIView is moving via animation, but when it reaches second UIView it moving under it. How to move First UIView over the second UIView?
Here is my code (self.openView is first UIView, self.showView is second UIView):
- (void)cardImage:(NSString *)cardContent{
self.cardOpenImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",cardContent]]];
self.cardOpenImage.frame = CGRectMake(0, 0, self.openView.frame.size.width, self.openView.frame.size.height);
UIImageView *cardBacksImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cardbacks.png"]];
cardBacksImage.frame = CGRectMake(0, 0, self.openView.frame.size.width, self.openView.frame.size.height);
[self.openView addSubview:cardBacksImage];
[UIView transitionFromView:cardBacksImage
toView:self.cardOpenImage
duration:1
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
[self moveToLeft:nil finished:nil context:nil];
}];
}
- (void)moveToLeft:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView animateWithDuration:1.0
delay:0
options:(UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction)
animations:^{
[UIView setAnimationDelegate:self];
self.openView.center = CGPointMake(247, 180);
}
completion:^(BOOL finished){
NSLog(@"Move to left done");
}];
}
[self.openView.superview bringSubviewToFront:self.openView];
Will bring self.openView
to the top of it's superview's view hierarchy. This will work assuming both of your UIViews
are subviews of the same superview.