简体   繁体   中英

How to translate the UIImagePickerController preview?

When I open UIImagePickerController() and set showsCameraControls = false , the camera preview sits against the top of the screen. How do I move this preview down so it is at the same location as when showCameraControls = true ?

Found the answer whilst trawling online:

// Create the UIImagePickerController without camera controls
var imagePicker: UIImagePickerController = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false

// Translate the camera preview down by 50px
let translate: CGAffineTransform = CGAffineTransformMakeTranslation(0.0, 50.0)
imagePicker.cameraViewTransform = translate

// Now add custom overlay
// ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM