如何使相机沿 y 轴叠加视图(swift 3)

how to make cameraOverlayView along the y axis (swift3)

我正在制作一个照片应用程序,我希望 imagePicker 屏幕上有红色块,以便在裁剪照片之前预先遮住照片。我的以下代码在顶部 x 轴上设置了障碍。我想沿着黄色矩形所在的整个 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

请尝试以下操作:

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