0

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. My following code gets a roadblock on the top x axis. I would like to place another red box along the entire y axis where the yellow rectangle is.

    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

enter image description here

1 Answers1

0

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
Vini App
  • 7,339
  • 2
  • 26
  • 43
  • How can I get it on all 4 sides. Right now it works great but its only on two sides. –  Aug 24 '17 at 03:52
  • `let blockView2 = UIView.init(frame: CGRect.init(x: self.view.frame.size.width-110, y: 170, width: 100, height: self.view.frame.size.height-320)) blockView1.backgroundColor = UIColor.yellow mainView.addSubview(blockView2)` You can add one more view like this – Vini App Aug 24 '17 at 04:10