Permalink
Browse files

Merge pull request #53 from gekitz/master

Appearance Bug
  • Loading branch information...
2 parents 75e499c + f908a89 commit ec42b364ff6a908978715f52e9382b7064865564 @myell0w committed May 18, 2012
Showing with 19 additions and 1 deletion.
  1. +19 −1 MTStatusBarOverlay.m
View
20 MTStatusBarOverlay.m
@@ -234,6 +234,9 @@ - (void)didChangeStatusBarFrame:(NSNotification *)notification;
- (void)applicationDidBecomeActive:(NSNotification *)notifaction;
- (void)applicationWillResignActive:(NSNotification *)notifaction;
+// returns the current frame for the detail view depending on the interface orientation
+- (CGRect)backgroundViewFrameForStatusBarInterfaceOrientation;
+
@end
@@ -344,7 +347,8 @@ - (id)initWithFrame:(CGRect)frame {
[self addSubview:detailView_];
// Create view that stores all the content
- backgroundView_ = [[UIView alloc] initWithFrame:statusBarFrame];
+ CGRect backgroundFrame = [self backgroundViewFrameForStatusBarInterfaceOrientation];
+ backgroundView_ = [[UIView alloc] initWithFrame:backgroundFrame];
backgroundView_.clipsToBounds = YES;
backgroundView_.autoresizingMask = UIViewAutoresizingFlexibleWidth;
oldBackgroundViewFrame_ = backgroundView_.frame;
@@ -442,6 +446,9 @@ - (id)initWithFrame:(CGRect)frame {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil];
+
+ // initial rotation, fixes the issue with a wrong bar appearance in landscape only mode
+ [self rotateToStatusBarFrame:nil];
}
return self;
@@ -861,6 +868,8 @@ - (void)rotateToStatusBarFrame:(NSValue *)statusBarFrameValue {
self.smallFrame = CGRectMake(self.frame.size.width - kWidthSmall, 0.f, kWidthSmall, self.frame.size.height);
}
+ self.backgroundView.frame = [self backgroundViewFrameForStatusBarInterfaceOrientation];
+
// if the statusBar is currently shrinked, update the frames for the new rotation state
if (shrinkedBeforeTransformation) {
// the oldBackgroundViewFrame is the frame of the whole StatusBar
@@ -1356,6 +1365,15 @@ - (void)updateProgressViewSizeForLabel:(UILabel *)label {
}
}
+- (CGRect)backgroundViewFrameForStatusBarInterfaceOrientation{
+
+ UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
+
+ return (UIInterfaceOrientationIsLandscape(interfaceOrientation) ?
+ CGRectMake(0, 0, kScreenHeight, kStatusBarHeight) :
+ CGRectMake(0, 0, kScreenWidth, kStatusBarHeight));
+}
+
////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark History Tracking

0 comments on commit ec42b36

Please sign in to comment.