diff --git a/TWStatus/TWStatus.m b/TWStatus/TWStatus.m index 417372a..22be2b3 100644 --- a/TWStatus/TWStatus.m +++ b/TWStatus/TWStatus.m @@ -98,8 +98,18 @@ + (void)dismissAfter:(NSTimeInterval)interval{ #pragma mark - orientation - (void)handleOrientationChange:(NSNotification *)notif { - [self layoutForOrientation]; - [self layout]; + // NOTE- In iOS7.1, statusBarOrientation property returns final value after the orientation is completed + // Hence do the layout with delay + if ([UIDevice currentDevice].systemVersion.floatValue >= 7.09) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(([UIApplication sharedApplication].statusBarOrientationAnimationDuration + .1) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self layoutForOrientation]; + [self layout]; + }); + } + else { + [self layoutForOrientation]; + [self layout]; + } } #pragma mark - private @@ -124,12 +134,22 @@ - (void)layoutForOrientation { case UIInterfaceOrientationLandscapeRight: t = CGAffineTransformMakeRotation(M_PI_2); - frame = CGRectMake(sizeAppFrame.width, 0, kTWStatusHeight, sizeAppFrame.height); + if ([UIApplication sharedApplication].statusBarHidden) { + frame = CGRectMake(sizeAppFrame.width-kTWStatusHeight, 0, kTWStatusHeight, sizeAppFrame.height); + } + else { + frame = CGRectMake(sizeAppFrame.width, 0, kTWStatusHeight, sizeAppFrame.height); + } break; case UIInterfaceOrientationPortraitUpsideDown: t = CGAffineTransformMakeRotation(M_PI); - frame = CGRectMake(0, sizeAppFrame.height, sizeAppFrame.width, kTWStatusHeight); + if ([UIApplication sharedApplication].statusBarHidden) { + frame = CGRectMake(0, sizeAppFrame.height - kTWStatusHeight, sizeAppFrame.width, kTWStatusHeight); + } + else { + frame = CGRectMake(0, sizeAppFrame.height, sizeAppFrame.width, kTWStatusHeight); + } break; } // Apply transform