Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set MTStatusBarOverlay regardless of the app status bar style #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MTStatusBarOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ typedef enum MTMessageType {
@property (nonatomic, copy) NSString *detailText;
// the delegate of the overlay
@property (nonatomic, unsafe_unretained) id<MTStatusBarOverlayDelegate> delegate;

// default is what the app sets
@property(nonatomic) UIStatusBarStyle statusBarStyle;

//===========================================================
#pragma mark -
Expand Down
10 changes: 6 additions & 4 deletions MTStatusBarOverlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ @implementation MTStatusBarOverlay

- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.statusBarStyle = [UIApplication sharedApplication].statusBarStyle;

CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;

// only use height of 20px even is status bar is doubled
Expand Down Expand Up @@ -673,7 +675,7 @@ - (void)showNextMessage {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(clearHistory) object:nil];

// update UI depending on current status bar style
UIStatusBarStyle statusBarStyle = [UIApplication sharedApplication].statusBarStyle;
UIStatusBarStyle statusBarStyle = self.statusBarStyle;
[self setStatusBarBackgroundForStyle:statusBarStyle];
[self setColorSchemeForStatusBarStyle:statusBarStyle messageType:messageType];
[self updateUIForMessageType:messageType duration:duration];
Expand Down Expand Up @@ -991,7 +993,7 @@ - (void)setShrinked:(BOOL)shrinked animated:(BOOL)animated {
}

// update status bar background
[self setStatusBarBackgroundForStyle:[UIApplication sharedApplication].statusBarStyle];
[self setStatusBarBackgroundForStyle:self.statusBarStyle];
}];
}

Expand Down Expand Up @@ -1072,10 +1074,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];

cell.textLabel.font = [UIFont boldSystemFontOfSize:10];
cell.textLabel.textColor = [UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleDefault ? kLightThemeHistoryTextColor : kDarkThemeHistoryTextColor;
cell.textLabel.textColor = self.statusBarStyle == UIStatusBarStyleDefault ? kLightThemeHistoryTextColor : kDarkThemeHistoryTextColor;

cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:12];
cell.detailTextLabel.textColor = [UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleDefault ? kLightThemeHistoryTextColor : kDarkThemeHistoryTextColor;
cell.detailTextLabel.textColor = self.statusBarStyle == UIStatusBarStyleDefault ? kLightThemeHistoryTextColor : kDarkThemeHistoryTextColor;
}

// step 3: set up cell value
Expand Down