简体   繁体   中英

Scale a UIView with animation but without Transform

I try to scale a UIView with a circle shape to make it double in size when I click on it.

my final target is to reproduce the apple music behavior: -When you click on a circle, it grows and pushes other circles around.

I m trying to achieve this with UIKit dynamics but the first problem is that animating a scale without CATransform (it doesn't work with collisions) fails.

at the end of the animation, even if width and height are 100, the final shape is a rectangle...

here is my code

func ballTapped(sender:UITapGestureRecognizer) {
        if sender.state == .Ended {
            collision.removeItem(sender.view!)
            let item = sender.view!
            var theFrame = item.frame
            theFrame.size.height = 100
            theFrame.size.width = 100
            UIView.animateWithDuration(0.5, animations: { () -> Void in
                    item.frame = theFrame
                }, completion: { (Bool) -> Void in
                    self.collision.addItem(sender.view!)
                }
            )
        }
    }
[UIView animateWithDuration:0.5
                     animations:^{

                         [UIView animateWithDuration: 0.5 delay: 0.0 options:UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveEaseInOut animations:^{

                             _iCarouselCarVW.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
                             _iCarBackView.hidden = YES;
                             NSLog(@"%f",self.view.frame.size.width);
                             _iCarouselCenterConstant.constant = self.view.frame.size.width/2 + 50;
                             [self.iCarouselCarVW setCurrentItemIndex:0];
                         } completion:^(BOOL finished)
                          {


                          }];

                         [self.view layoutIfNeeded]; // Called on parent view
                     }];

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