Skip to content

Commit

Permalink
fix(ios): status bar background color crash fix ios13 (#11370)
Browse files Browse the repository at this point in the history
* fix(ios): status bar background color crash fix ios13

* fix(ios): status bar background color crash fix ios13

* fix(ios): status bar background color crash fix ios13

* fix(ios): status bar background color crash fix ios13
  • Loading branch information
vijaysingh-axway authored and lokeshchdhry committed Dec 11, 2019
1 parent fa5866a commit b999f27
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
21 changes: 18 additions & 3 deletions iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,24 @@ - (void)setStatusBarBackgroundColor:(id)value
ENSURE_UI_THREAD(setStatusBarBackgroundColor, value);
ENSURE_SINGLE_ARG(value, NSString);

UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = [[TiUtils colorValue:value] _color];
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
#if IS_SDK_IOS_13
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
CGRect frame = keyWindow.windowScene.statusBarManager.statusBarFrame;
UIView *view = [keyWindow viewWithTag:TI_STATUSBAR_TAG];
if (!view) {
view = [[UIView alloc] initWithFrame:frame];
view.tag = TI_STATUSBAR_TAG;
[keyWindow addSubview:view];
}
view.frame = frame;
view.backgroundColor = [[TiUtils colorValue:value] _color];
#endif
} else {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = [[TiUtils colorValue:value] _color];
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ enum {

#define TI_SEARCHBAR_HEIGHT 56

#define TI_STATUSBAR_TAG 11101

#ifdef DEBUG
#define FRAME_DEBUG(f) \
NSLog(@"FRAME -- size=%fx%f, origin=%f,%f", f.size.width, f.size.height, f.origin.x, f.origin.y);
Expand Down
20 changes: 20 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
withObject:nil
afterDelay:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]];

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
[self performSelector:@selector(updateStatusBarView)
withObject:nil
afterDelay:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]];
#endif

[super viewWillTransitionToSize:size
withTransitionCoordinator:coordinator];
[self willChangeSize];
Expand Down Expand Up @@ -1044,6 +1050,20 @@ - (void)cleanupWindowDecorations
}
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
- (void)updateStatusBarView
{
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
CGRect frame = keyWindow.windowScene.statusBarManager.statusBarFrame;
UIView *view = [keyWindow viewWithTag:TI_STATUSBAR_TAG];
if (view) {
view.frame = frame;
}
}
}
#endif

- (TiViewProxy *)safeAreaView
{
return self.safeAreaViewProxy;
Expand Down

0 comments on commit b999f27

Please sign in to comment.