title: Setting cameraViewTransform dynamically for iOS 8
body: <p>I am working on a camera app where I am supposed to show a camera inside <a href="https://i.stack.imgur.com/y9mDR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y9mDR.png" alt="enter image description here"></a></p>
  
  <p>I am using <code>camView.cameraViewTransform = CGAffineTransformMakeScale(1.0, 1.0) ;</code> but getting different results for different devices and a black bar in between tab bar and camera. If I change the value of <code>scaling</code> the camera is too zoomed up. Any help in this matter would be very appreciated.</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      [self prepareCamera];
  }
  
  - (void)viewDidAppear:(BOOL)animated{
      [super viewDidAppear:NO];
      [self launchCamera];
  }
  
  - (void)prepareCamera{
      camView = [[UIImagePickerController alloc] init];
      camView.delegate = self;
      camView.sourceType = UIImagePickerControllerSourceTypeCamera;
      camView.showsCameraControls = NO;
      [self resizeCameraView];
  }
  
  
  - (void)resizeCameraView{
      CGSize screenSize = self.view.bounds.size;
      // set the aspect ratio of the camera
      float heightRatio = 4.0f / 3.0f;
      // calculate the height of the camera based on the screen width
      float cameraHeight = screenSize.width * heightRatio;
      // calculate the ratio that the camera height needs to be scaled by
      float scale = screenSize.height / cameraHeight;
      // move the controller to the center of the screen
      camView.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight) / 2.0);
      // concatenate the scale transform
      camView.cameraViewTransform = CGAffineTransformScale(camView.cameraViewTransform, scale, scale);
  }
  
  - (void)launchCamera{
          [camSubView addSubview:camView.view];
          [camView viewWillAppear:YES];
          [camView viewDidAppear:YES];
  }
  </code></pre>