问题
I am using following code to animate the appearance of selectionMoreOptionView
[selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 0)];
[self.view insertSubview:selectionMoreOptionView aboveSubview:lightBoxView];
[lightBoxView setAlpha:0.0];
[UIView animateWithDuration:5.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
[lightBoxView setAlpha:0.5];
[selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 100)];
} completion:^(BOOL finished) {
}];
But it is not animating instead it just appears at once without animating. What i am doing wrong?
回答1:
Simply try this
[UIView animateWithDuration:.5 animations:^(void){
[lightBoxView setAlpha:0.5];
[selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 100)];
}];
回答2:
The animation was working fine the problem was that i had two buttons inside the view big enough to cover all of the view. The views property Clip Subviews was unchecked. I had thought when a parent resizes it effects its child's automatically, but it don't in some cases when parent do not clip its subviews. Thanks everybody for your reply :)
回答3:
check your
[selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 100)];
I think XY co-ordinates going out of viewController. Try to bring it in the ViewController area,as of X should be possibly less than 320 and y<480 so that you can see your view.
来源:https://stackoverflow.com/questions/18184412/uiview-animation-not-working-to-resize-view