在swift中使用相機的API看起來很不同,但我很難將相機對焦在一個點上。當用戶點擊我希望相機專注於這一點用Swift設置拍照點的相機對焦
屏幕這是我的代碼:
func focusCamera(point:CGPoint)
{
var screenRect:CGRect = bounds
var focusX = Float(point.x/screenRect.width)
var focusY = Float(point.y/screenRect.height)
_currentDevice.lockForConfiguration(nil)
_currentDevice.setFocusModeLockedWithLensPosition(focusX)
{
time in
self._currentDevice.unlockForConfiguration()
}
_currentDevice.setFocusModeLockedWithLensPosition(focusY)
{
time in
self._currentDevice.unlockForConfiguration()
}
}
但它似乎沒有工作。
任何建議都比歡迎!
能否請您提供更多信息...我是初學者,我不知道在哪裏把這段代碼 – 2015-04-08 22:14:24