Skip to content

Commit

Permalink
Support different Orientations. See cruffenach#7
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Feb 18, 2014
1 parent c8238b3 commit fe453df
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions CRToast/CRToast.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ @interface CRToastView : UIView
#pragma mark - Layout Helper Functions

static CGFloat const CRStatusBarDefaultHeight = 44.0f;
static CGFloat const CRStatusBariPhoneLandscape = 30.0f;
static CGFloat const CRStatusBariPhoneLandscape = 33.0f;

static CGFloat CRGetStatusBarHeight() {
return (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) ?
Expand Down Expand Up @@ -638,7 +638,16 @@ - (void)addNotification:(CRToast*)notification {
- (void)displayNotification:(CRToast*)notification {
_notificationWindow.hidden = NO;
CGSize notificationSize = CRNotificationViewSize(notification.notificationType);
_notificationWindow.rootViewController.view.frame = CGRectMake(0, 0, notificationSize.width, notificationSize.height);

if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
_notificationWindow.rootViewController.view.frame = CGRectMake(0, 0, notificationSize.height, notificationSize.width);
} else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
_notificationWindow.rootViewController.view.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width-notificationSize.height, 0, notificationSize.height, notificationSize.width);
} else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) {
_notificationWindow.rootViewController.view.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height, notificationSize.width, notificationSize.height);
} else {
_notificationWindow.rootViewController.view.frame = CGRectMake(0, 0, notificationSize.width, notificationSize.height);
}

UIView *statusBarView = notification.statusBarView;
statusBarView.frame = _notificationWindow.rootViewController.view.bounds;
Expand Down

0 comments on commit fe453df

Please sign in to comment.