我正在尝试复制iPhone Camera app默认快门动画。
也许有人试过这样做并有一些提示要分享?
答案 0 :(得分:20)
好吧,我发现了这个地方:
CATransition *shutterAnimation = [CATransition animation];
[shutterAnimation setDelegate:self];
[shutterAnimation setDuration:0.6];
shutterAnimation.timingFunction = UIViewAnimationCurveEaseInOut;
[shutterAnimation setType:@"cameraIris"];
[shutterAnimation setValue:@"cameraIris" forKey:@"cameraIris"];
CALayer *cameraShutter = [[CALayer alloc]init];
[cameraShutter setBounds:CGRectMake(0.0, 0.0, 320.0, 425.0)];
[self.layer addSublayer:cameraShutter];
[self.layer addAnimation:shutterAnimation forKey:@"cameraIris"];
这是默认的iPhone相机快门动画。
答案 1 :(得分:2)
在Swift 3.0中......
let shutterAnimation = CATransition.init()
shutterAnimation.duration = 0.6
shutterAnimation.timingFunction = CAMediaTimingFunction.init(name:
kCAMediaTimingFunctionEaseInEaseOut)
shutterAnimation.type = "cameraIris"
shutterAnimation.setValue("cameraIris", forKey: "cameraIris")
let shutterLayer = CALayer.init()
shutterLayer.bounds = self.view.bounds
self.view.layer.addSublayer(shutterLayer)
self.view.layer.add(shutterAnimation, forKey: "cameraIris")