gpt4 book ai didi

ios - 如何使用像 TikTok App 这样的平移手势来缩放相机

转载 作者:行者123 更新时间:2023-11-28 05:48:38 25 4
gpt4 key购买 nike

我正在开发录像机应用程序,我想要像 Titok 这样的功能,例如在平移手势上,他们正在缩放相机我使用了以下代码,但使用此代码我可以通过拖动进行缩放,这是不可行的我想继续放大和缩小。

@objc func previewPan(recognizer:UIPanGestureRecognizer) {
viewShoot.isHidden = false
//DispatchQueue.main.async {


if recognizer.state == UIGestureRecognizerState.began {

//self.StartRecording()

//self.startPoint = recognizer.location(in: self.viewShoot)
startPoint = recognizer.location(in: self.viewAnimate)

self.zoomAtStart = self.recorder.videoZoomFactor

} else if recognizer.state == UIGestureRecognizerState.changed {

//let newPoint = recognizer.location(in: self.viewShoot)
let newPoint = recognizer.location(in: self.viewAnimate)

let scale = self.startPoint.y / newPoint.y
var newZoom = scale * self.zoomAtStart

if newZoom > self.maxZoomFactor {
newZoom = self.maxZoomFactor
} else if newZoom < self.minZoomFactor {
newZoom = self.minZoomFactor
}
self.recorder.videoZoomFactor = newZoom

//------->
//self.viewShoot.isHidden = false
//self.viewAnimate.isHidden = false

//self.view.bringSubview(toFront: self.viewShoot)
self.view.bringSubview(toFront: self.viewAnimate)

let translation = recognizer.translation(in: self.view)

//self.viewShoot.center = CGPoint(x: self.viewShoot.center.x + translation.x, y: self.viewShoot.center.y + translation.y)
self.viewAnimate.center = CGPoint(x: self.viewAnimate.center.x + translation.x, y: self.viewAnimate.center.y + translation.y)


recognizer.setTranslation(CGPoint.zero, in: self.view)

} else if recognizer.state == UIGestureRecognizerState.ended {

//self.StopRecording()

UIView.animate(withDuration: 0.250) {
//self.viewShoot.frame = self.originalPossion
self.viewAnimate.frame = self.originalPossion
}
}
//}
}

请帮忙!

最佳答案

我已经使用 NextLevelZoom 解决了这个问题

关于ios - 如何使用像 TikTok App 这样的平移手势来缩放相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com