Reputation: 2395
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!)
}
)
}
}
Upvotes: 1
Views: 210
Reputation: 57
[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
}];
Upvotes: 1