I have tried several variations on the following to no avail. What I want is a curl down transition that shows some things and then a curl transition back up that does the opposite. There is transparency so the effect is that of a clear thing rolling down over a view. This is the function that gets called on the roll up and the roll down:
-(void) setVisibility:(BOOL)isVisible animated:(BOOL)animated{
if (isVisible){
self.topFold.hidden = YES;
}
[UIView transitionWithView:self
duration:1.0f
options:isVisible ? UIViewAnimationOptionTransitionCurlDown : UIViewAnimationOptionTransitionCurlUp
animations:^{
self.imageView.hidden = !isVisible;
self.background.hidden = !isVisible;
self.bottomCornerFold.hidden = !isVisible;
}
completion:^(BOOL finished){
if (!isVisible){
self.topFold.hidden = NO;
}
}
];
}
I've tried a billion different scenarios but this one is the closest. The problem though is that when it runs with isVisible
= YES
, topFold
stays visible until after the transitions are done. That is to say, the new stuff rolls down over it, as if there's a copy of the view that the new stuff comes on top of. And then once it's done, it replaces the whole thing with the correct version.
To clarify, I'm trying to hide topFold
before any animation starts but for some reason it insists on hanging around until the animation is done. Would love a pointer here.
From the clumsy but effective department, I nested the two animations, one inside the other's completion block. Looks like this and works:
[UIView transitionWithView:self
duration:0.0f
options:nil
animations:^{
if (isVisible){
self.topFold.hidden = YES;
}
}
completion:^(BOOL finished){
[UIView transitionWithView:self
duration:1.0f
options:isVisible ? UIViewAnimationOptionTransitionCurlDown : UIViewAnimationOptionTransitionCurlUp
animations:^{
self.imageView.hidden = !isVisible;
self.background.hidden = !isVisible;
self.bottomCornerFold.hidden = !isVisible;
}
completion:^(BOOL finished){
if (!isVisible){
self.topFold.hidden = NO;
}
}
];
}
];