最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - Camera zoom factor 1x to 3x over a duration of 0.25 seconds for iPhone - Stack Overflow

programmeradmin5浏览0评论

I am working with the builtInWideAngleCamera back main camera for iPhone.

Using the method ramp(toVideoZoomFactor:withRate:) I am trying to create a function that smoothly transitions from zoom factor 1x to 3x over a duration of 0.25 seconds. Then in another function transition from zoom factor 3x back to 1x over a duration of 0.25 seconds.

I have tried a range of withRate values and am getting unexpected results and very slow camera zooming.


Documentation:

(tovideozoomfactor:withrate:)


Code:

func cameraZoomIn() {
    if let deviceCameraSelected = deviceCameraSelected {
        do {
            try deviceCameraSelected.lockForConfiguration()
            try deviceCameraSelected.ramp(toVideoZoomFactor: 3, withRate: 0.25)
            deviceCameraSelected.unlockForConfiguration()
        } catch {
            print("Error: \(error)")
        }
    }
}

func cameraZoomOut() {
    if let deviceCameraSelected = deviceCameraSelected {
        do {
            try deviceCameraSelected.lockForConfiguration()
            try deviceCameraSelected.ramp(toVideoZoomFactor: 1, withRate: 0.25)
            deviceCameraSelected.unlockForConfiguration()
        } catch {
            print("Error: \(error)")
        }
    }
}

Questions:

1 - What is the correct withRate value to achieve a zoom factor 1x to 3x over a duration of 0.25 seconds and a zoom factor 3x to 1x over a duration of 0.25 seconds?

2 - The documentation says the zoom transition is a visually linear transition but how can I get a transition curve that is curveEaseInOut similar to regular UIView.animate transitions?

发布评论

评论列表(0)

  1. 暂无评论