有谁知道 phone 屏幕顶部与相机图像预览开始之间的像素距离?
Does anyone know the distance in pixels between the top of the phone screen to the start of the image preview in the camera?
我正在尝试构建自定义相机叠加层,需要知道拍照时图像预览上方黑色工具栏的高度。有人知道吗?下图:
您可以通过记录感兴趣的视图层次来找到问题的答案。
制作一个递归视图日志记录函数,类似...
func logsubviews(view: UIView, indent: Int)->Void {
//indenting
var indent = indent + 1
var indentString = ""
for i in 0..<indent {
indentString = " \(indentString)"
}
//logging
println("\(indentString) \(view)")
for subview in view.subviews {
self.logsubviews(subview as UIView, indent: indent)
}
}
然后在呈现 imagePicker 的视图层次结构后记录它:
@IBAction func invokeImagePicker(sender: AnyObject) {
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .Camera
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion:{
()->Void in
self.logsubviews(imagePicker.view, indent: 0)
})
}
您将获得 imagePickerController 的视图及其各自框架的精美打印输出。
我正在尝试构建自定义相机叠加层,需要知道拍照时图像预览上方黑色工具栏的高度。有人知道吗?下图:
您可以通过记录感兴趣的视图层次来找到问题的答案。
制作一个递归视图日志记录函数,类似...
func logsubviews(view: UIView, indent: Int)->Void {
//indenting
var indent = indent + 1
var indentString = ""
for i in 0..<indent {
indentString = " \(indentString)"
}
//logging
println("\(indentString) \(view)")
for subview in view.subviews {
self.logsubviews(subview as UIView, indent: indent)
}
}
然后在呈现 imagePicker 的视图层次结构后记录它:
@IBAction func invokeImagePicker(sender: AnyObject) {
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .Camera
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion:{
()->Void in
self.logsubviews(imagePicker.view, indent: 0)
})
}
您将获得 imagePickerController 的视图及其各自框架的精美打印输出。