ios - 自定义segue完成后相机关闭?
问题描述
我正在尝试使用自定义过渡到全屏自定义相机。当我使用慢速淡入淡出动画这样做时,完成动画后它会变黑。
动画开始时似乎工作的相机突然消失了,留下了黑色背景。
如何使过渡正常工作?
代码:
主VC:
@objc func buttonUp(_ sender: UIButton) {
toCam.transform = CGAffineTransform.identity.scaledBy(x: 1, y: 1)
toCam.backgroundColor = .yellow
segue()
}
func segue() {
performSegue(withIdentifier: "GoToCam", sender: self)
}
自定义 segue 类:
class goToCamAnimCustom: UIStoryboardSegue {
override func perform() {
scale()
}
func scale() {
guard let destinationView = self.destination.view else {
// Fallback to no fading
self.source.present(self.destination, animated: false, completion: nil)
return
}
destinationView.alpha = 0
self.source.view?.addSubview(destinationView)
UIView.animate(withDuration: CATransaction.animationDuration(), animations: {
destinationView.alpha = 0.5
}, completion: { _ in
self.source.present(self.destination, animated: false, completion: nil)
})
}
}
解决方案
推荐阅读
- google-apps-script - 如何使用 GAS 动态嵌入 trello 卡?
- git - 使 .gitignore 只接受与字幕相关的扩展
- function - Option时如何在函数中返回值
是 Some(),或者当它是 None 时以 None 退出? - python - 如何将来自 Matlab 的 Chua 吸引子的代码翻译成 Python?
- javascript - 导航栏活动链接动画
- wpf - 如何仅在没有活动时显示工具提示?
- python - 在 Python/Django 中将 HTML 转换为 Draft-JS ContentState
- eclipse - Maven 依赖导致 servlet 中的 NoClassDefFoundError
- php - 如何插入多个ID并保存在数据库中
- amazon-web-services - AWS CloudFormation - 从通过参数传入的 FQDN 计算 IP