我尝试使用圆形缩放UIView
,以便在点击它时将其加倍。
我的最终目标是重现苹果音乐行为: - 当你点击一个圆圈时,它会增长并推动其他圆圈。
我试图用UIKit
动态实现这一点,但第一个问题是没有CATransform
的动画(不适用于碰撞)动画失败。
在动画结束时,即使宽度和高度为100, 最终的形状是一个矩形...
这是我的代码
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!)
}
)
}
}
答案 0 :(得分:0)
[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
}];