我目前在该部分中有一个透明部分的自定义视图。我目前正在使用:
创建它override func drawRect(rect: CGRect) {
bgColor.setFill()
UIRectFill(rect)
let holeRect = imageView.frame
let intersect = CGRectIntersection(holeRect, rect)
UIColor.clearColor().setFill()
UIRectFill(intersect)
}
我还想为透明的内部视图设置动画,首先它会变小,然后将透明部分设置为更大的动画......我将如何实现这一目标?
我目前将此作为我的动画
func startAnimating(completion: () -> Void) {
let shrinkDuration = animationDuration * 0.5
let growDuration = animationDuration * 0.9
self.setNeedsDisplay()
UIView.animateWithDuration(shrinkDuration, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 10, options: .CurveEaseInOut, animations: { () -> Void in
//Do Animation
let scaleTransform = CGAffineTransformMakeScale(0.75, 0.75)
self.imageView.transform = scaleTransform
}) { (finished) -> Void in
self.setNeedsDisplay()
UIView.animateWithDuration(growDuration, animations: { () -> Void in
let scaleTransform = CGAffineTransformMakeScale(20, 20)
self.imageView.transform = scaleTransform
self.alpha = 0
}, completion: { (finished) -> Void in
self.removeFromSuperview()
completion()
})
}
}
虽然
没有调整holeRect部分的大小答案 0 :(得分:0)
尝试添加以下动画块
UIView.animateWithDuration(0.2, animations: {
//animate your alpha property here
}, completion: { finished in
//do whatever you need to do when the animation finish
})