Skip to content

Instantly share code, notes, and snippets.

@curt-labs
Created April 18, 2011 16:09
Show Gist options
  • Save curt-labs/925615 to your computer and use it in GitHub Desktop.
Save curt-labs/925615 to your computer and use it in GitHub Desktop.
if (overlayView == nil) {
overlayView = [[MyOverlayView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[overlayView setBounds:[[UIScreen mainScreen] bounds]];
[overlayView setTag:55];
}
#import <UIKit/UIKit.h>
@interface MyOverlayView : UIView {
}
- (void)awakeFromNib;
- (void)dealloc;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
@end
@implementation MyOverlayView
// MPMoviePlayerController will play movies full-screen in
// landscape mode, so we must rotate MyOverlayView 90 degrees and
// translate it to the center of the screen so when it draws
// on top of the playing movie it will display in landscape
// mode to match the movie player orientation.
//
- (void)awakeFromNib
{
CGAffineTransform transform = self.transform;
// Rotate the view 90 degrees.
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
UIScreen *screen = [UIScreen mainScreen];
// Translate the view to the center of the screen
transform = CGAffineTransformTranslate(transform,
((screen.bounds.size.height) - (self.bounds.size.height))/2,
0);
self.transform = transform;
CGRect newFrame = self.frame;
newFrame.origin.x = 190;
self.frame = newFrame;
}
- (void)dealloc {
[super dealloc];
}
// Handle any touches to the overlay view
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* touch = [touches anyObject];
if (touch.phase == UITouchPhaseBegan)
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:OverlayViewTouchNotification object:nil];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment