0
votes

I have an app that uses the iPhone camera and puts an overlay over the camera. However it all works fine and i have managed to rotate the UIView to landscape but their is a 20px gap at the top of the view although i have set the positioning to (0,0,480,320).

starContainerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 480.0, 320.0)]     autorelease]; 
 UIImageView *overlayViewNew = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,480.0,320.0)];
 UIImage *OverlayImage = [[UIImage imageNamed:@"overlay.png"] autorelease];
 overlayViewNew.image = OverlayImage;
 [starContainerView addSubview:overlayViewNew];

So as you can see above I have set the UIView and set the UIIMageView and assigned a UIImage to that UIImageview and then added it to a subview of the view.

Here is the code I use to rotate the View.

- (void) accelerometer:(UIAccelerometer *)accelerometer
   didAccelerate:(UIAcceleration *)acceleration {
     if (fabsf(acceleration.x) > -1.0) {
       CGAffineTransform landscapeTransform =     CGAffineTransformMakeRotation(degreesToRadian(90));
       landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);
       [self.starContainerView setTransform:landscapeTransform];
     }
   }

I just cant seem to get it to fill that gap! Can i also say that no rocket science was involved whilst developing this but I still cant find the answer.

2

2 Answers

0
votes

A 20px gap might have something to do with the status bar not being hidden properly. Make sure you have this in your info.plist:

<key>UIStatusBarHidden</key> 
<true />
0
votes

If was down to the following code. I played about with the figures below and this worked.

CGAffineTransform landscapeTransform =     CGAffineTransformMakeRotation(degreesToRadian(90)); 
  landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +80.0);