CGAffineTransformMakeScale实现微信右上角菜单缩放动画

类似微信右上角扫一扫弹出菜单那个动画:

view.layer.anchorPoint = CGPointMake(1.0, 0)
view.transform = CGAffineTransformMakeScale(0, 0)
UIView.animateWithDuration(0.2) {
    view.transform = CGAffineTransformIdentity
    view.alpha = 1
}

简单解释下:anchorPoint是缩放的旋转点,point分别为x和y方向,注意区间是0和1,我们这里是右上角所以用的1

缩放初始比例CGAffineTransformMakeScale也是x和y方向,我们初始希望两个方向都没有,所以用的这个。

alpha那个是可选的,最好在view展示之前已经设置为alpha = 0,不然总会闪缩一下

Leave a Reply

Your email address will not be published. Required fields are marked *