From 28997922e4dd1cb8fb57ede24f56a6071009c683 Mon Sep 17 00:00:00 2001 From: Bruno Wernimont Date: Sat, 4 Aug 2012 09:04:01 +0200 Subject: [PATCH] Fix issue in landscape --- BWStatusBarOverlay/BWStatusBarOverlay.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BWStatusBarOverlay/BWStatusBarOverlay.m b/BWStatusBarOverlay/BWStatusBarOverlay.m index 7c77c7a..e96ec09 100644 --- a/BWStatusBarOverlay/BWStatusBarOverlay.m +++ b/BWStatusBarOverlay/BWStatusBarOverlay.m @@ -96,9 +96,15 @@ - (id)init { self = [super initWithFrame:CGRectZero]; if (self) { self.windowLevel = UIWindowLevelStatusBar + 1; - self.frame = [UIApplication sharedApplication].statusBarFrame; self.animation = BWStatusBarOverlayAnimationTypeFade; + BOOL isPortrait = UIDeviceOrientationIsPortrait(STATUS_BAR_ORIENTATION); + CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; + CGFloat statusBarHeight = (isPortrait) ? statusBarFrame.size.height : statusBarFrame.size.width; + CGFloat statusBarWidth = (isPortrait) ? statusBarFrame.size.width : statusBarFrame.size.height; + + self.frame = CGRectMake(0, 0, statusBarWidth, statusBarHeight); + _contentView = [[UIView alloc] initWithFrame:self.frame]; self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth; [self addSubview:self.contentView]; @@ -108,7 +114,7 @@ - (id)init { [self.contentView addSubview:_progressView]; _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; - self.activityView.frame = CGRectMake(4, 4, CGRectGetHeight(self.frame) - 4 * 2, CGRectGetHeight(self.frame) - 4 * 2); + self.activityView.frame = CGRectMake(4, 4, statusBarHeight - 4 * 2, statusBarHeight - 4 * 2); self.activityView.hidesWhenStopped = YES; if ([self.activityView respondsToSelector:@selector(setColor:)]) { // IOS5 or greater @@ -125,8 +131,8 @@ - (id)init { _textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.textLabel.frame = CGRectMake(CGRectGetWidth(self.activityView.frame) + 10, 0, - CGRectGetWidth(self.frame) - (CGRectGetWidth(self.activityView.frame) * 2) - (10 * 2), - CGRectGetHeight(self.frame)); + statusBarWidth - (CGRectGetWidth(self.activityView.frame) * 2) - (10 * 2), + statusBarHeight); self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.font = TEXT_LABEL_FONT; self.textLabel.textAlignment = UITextAlignmentCenter;