I am wondering how to animate the scale of a mask on a uiimageview. Example images attached. The gray boxes are the image background of my uiviewcontroller and is not part of th
This works for me for a circular mask animation on a map view, you should be able to replace out the map view with an image view, the mask is an oval around the bounds and animates between being the original size and being inset by 5 points repeatedly:
func setupMapMask() {
let largeCirclePath = UIBezierPath(ovalInRect: mapView.bounds).CGPath
let mask = CAShapeLayer()
mask.path = largeCirclePath
mask.backgroundColor = UIColor.blackColor().CGColor
mapView.layer.mask = mask
let smallCirclePath = UIBezierPath(ovalInRect: CGRectInset(mapView.bounds, 5.0, 5.0)).CGPath
let anim = CABasicAnimation(keyPath: "path")
anim.toValue = smallCirclePath
anim.duration = 0.5
anim.repeatCount = Float.infinity
anim.autoreverses = true
mask.addAnimation(anim, forKey: "path")
}