I'm trying t开发者_JS百科o add a sub view with Core-Animation using the attached code. First time it happens as expected, but after that there's a flash of white in the place of the sub-view before it's fully pushed.
// Add the picker
viewToPush.frame = CGRectMake(0,185,320, 258);
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromTop];
[self.view addSubview:viewToPush];
[viewToPush.layer addAnimation:animation forKey:nil];
btw, in order to remove the subView I just use
[viewToRemove removeFromSuperview];
10x
Why do you add the animation to the viewToPush
's layer, not the super view's? I suspect the layer of viewToPush
is not stable as you remove the view from the super view. Do you have many views that can act as viewToPush
or viewToRemove
so they have to be dynamically allocated? Otherwise I would just change their hidden properties to implement such animations.
精彩评论