Created
April 18, 2011 16:09
-
-
Save curt-labs/925615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (overlayView == nil) { | |
overlayView = [[MyOverlayView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; | |
[overlayView setBounds:[[UIScreen mainScreen] bounds]]; | |
[overlayView setTag:55]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface MyOverlayView : UIView { | |
} | |
- (void)awakeFromNib; | |
- (void)dealloc; | |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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