UIView Animation not working to resize view

*爱你&永不变心* 提交于 2019-12-11 02:40:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!