简体   繁体   English

如何使y轴上的cameraOverlayView(swift3)

[英]how to make cameraOverlayView along the y axis (swift3)

I am making a photo app that I want the imagePicker screen to have blocks of red to pre mask the photo before it crops. 我正在制作一个照片应用程序,我希望imagePicker屏幕上有红色的块以在照片裁剪之前对其进行预遮罩。 My following code gets a roadblock on the top x axis. 我的以下代码在顶部x轴上设置了障碍。 I would like to place another red box along the entire y axis where the yellow rectangle is. 我想在整个黄色矩形所在的y轴上放置另一个红色框。

    let blockView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: 150))

           blockView.backgroundColor = UIColor.red

    imagePicker.cameraOverlayView = blockView

在此处输入图片说明

Please try the following : 请尝试以下方法:

let mainView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height-150))

let blockView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: 150))
blockView.backgroundColor = UIColor.red

let blockView1 = UIView.init(frame: CGRect.init(x: 0, y: 170, width: 100, height: self.view.frame.size.height-320))
blockView1.backgroundColor = UIColor.green

mainView.addSubview(blockView)
mainView.addSubview(blockView1)

imagePicker.cameraOverlayView = mainView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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