title: Custom Camera View - Cannot change the frame size of the cameraLayout UIImagePicker, Swift
body: <p>I'm trying to make a custom camera view, basically. I am stuck changing the size of the image view inside of the UIImagePicker. By the image view, I mean the window that shows the view of the camera. I hope it will be more clear from the picture. It is the view inside of that red square (I drawed that red square manually to show you, do not think it is from code).</p>
  
  <p><a href="https://i.stack.imgur.com/capwb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/capwb.jpg" alt="sample camera view"></a></p>
  
  <p>Whatever I tried so far could not help me to change the size of that red rectangular area. Below is what I have so far:</p>
  
  <pre><code>@IBAction func takePhoto(sender: UIButton) {
      if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
          imagePicker =  UIImagePickerController()
          imagePicker.delegate = self
          imagePicker.sourceType = .Camera
          imagePicker.allowsEditing = false
          imagePicker.showsCameraControls = false
  
          //Create view
          let customViewController = CustomCameraViewController(
              nibName:"CustomCameraViewController",
              bundle: nil
          )
          let customView:CustomCameraView = customViewController.view as! CustomCameraView
  
          //Assignments
          customView.frame = self.imagePicker.view.frame
          customView.delegate = self
          self.imagePicker.cameraOverlayView?.frame.size = customView.image.frame.size
  
          presentViewController(imagePicker,
              animated: true,
              completion: {
                  self.imagePicker.cameraOverlayView = customView
              }
          )
      }else{
          //Alert
          let alert = UIAlertController(title: "Üzgünüz, kameranızı açamadık!", message: "Telefonunuz kamerayı desteklemiyor veya açmamıza izin verilmemiş. İzin vermek isterseniz ayarlardan izni açabilirsiniz.", preferredStyle: UIAlertControllerStyle.Alert)
  
          //Creating actions
          let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default){
              UIAlertAction in
              NSLog("OK is Pressed. Proceeding...")
          }
  
          //Adding actions
          alert.addAction(okAction)
  
          //Display alert
          self.presentViewController(alert, animated: true, completion: nil)
      }
  }
  </code></pre>
  
  <p>I am trying to accomplish whole custom view thing from a xib file and it is related to CustomCameraView class. I set up two delegate methods to the CustomCameraView in able to use those but these are not necessary for this question so I am not gonna post the code but still I think you might need to know. What is related to the question is the xib file, so please find it below:</p>
  
  <p><a href="https://i.stack.imgur.com/ogg3l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ogg3l.png" alt="CustomCameraViewController.xib file"></a></p>
  
  <p>The buttons are showing up at where they supposed to be however I cant make use of that imageView. I created an image view here so that I can take its frame.size and set to the picker's frame.size (you can see this in my code listing). And of coruse the reference to that image view is in CustomCameraView class, so I am reaching from that class as you might notice also.</p>
  
  <p>I have been trying for a whole day honestly yet I could not find a solution for that either or myself on net. I have read AVFoundation also but seems like there is not a clear explanation of how to set the frame size of that view in AVFoundation documentations as in UIImagePicker so I just decided to ask you guys as I am so lost in the project and cannot think another way right now.</p>
  
  <p>I would be really appreciate if you can help me. Let me know if you need further information.</p>
  
  <p>Thanks!</p>