简体   繁体   中英

Animation block cannot resize UiView, but can move it

I have a UIView on top of my appdelegate window. When I try to resize it to make it disappear, the animation doesn't work.

TLDR : cannot resize a UIView with UIAnimation block, but can move it

[UIView animateWithDuration:0.3
                      delay:0
                    options: UIViewAnimationCurveEaseIn
                 animations:^{ 
                     CGRect frame = viewMore.frame;
                     frame.size.height = 0;
                     viewMore.frame = frame;

                 } 
                 completion:^(BOOL finished){

                 }];

But, if I want to move the view, using this code, it works like charm. Example :

[UIView animateWithDuration:0.3
                      delay:0
                    options: UIViewAnimationCurveEaseIn
                 animations:^{ 
                    CGPoint centerMore =    viewMore.center;
                     centerMore.y += viewMore.frame.size.height;
                     viewMore.center = centerMore;


                 } 
                 completion:^(BOOL finished){


                 }];

viewMore has 2 UIButton subviews. The same code works to resize a UIWebView There are something that I don't understand. You are my only hope (well no, you're not :) )

Well, The problem was that the subviews (UIButton with image) weren't resize. The solution : Set the clipsToBounds to YES on the view to resize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM