此函数成功地为imagePickerController提供了overlayView。 snapButton子视图不可见。如何将子视图添加到cameraOverlayView?
func showImagePickerForSourceType(sourceType: UIImagePickerControllerSourceType){
imagePickerController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
imagePickerController.sourceType = sourceType
imagePickerController.delegate = self
if (sourceType == UIImagePickerControllerSourceType.Camera){
imagePickerController.showsCameraControls = false
let overlayView = UIView(frame: CGRectMake(0, self.view.frame.width, self.view.frame.width, self.view.frame.height-self.view.frame.width))
overlayView.backgroundColor = UIColor.whiteColor()
overlayView.alpha = 1.0 // tried this to make sure subview wasn't hiding behind
println(overlayView)
let snapButton = UIView(frame: CGRectMake(self.view.frame.width/2-22, self.view.frame.height-200, 44, 44))
snapButton.layer.cornerRadius = 22
snapButton.userInteractionEnabled = true
snapButton.backgroundColor = UIColor.blackColor()
overlayView.addSubview(snapButton)
overlayView.bringSubviewToFront(snapButton)
imagePickerController.cameraOverlayView = overlayView
}
self.presentViewController(self.imagePickerController, animated: true, completion: nil)
}