Skip to content
Merged
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
14 changes: 11 additions & 3 deletions lib/ios/RNNTitleViewHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

@implementation RNNTitleView

- (void)layoutSubviews {
CGFloat heightSum = _titleLabel.frame.size.height + _subtitleLabel.frame.size.height;
CGFloat yOffset = (self.frame.size.height - heightSum) / 2;

[_titleLabel setFrame:CGRectMake(0, yOffset, self.frame.size.width, _titleLabel.frame.size.height)];
[_subtitleLabel setFrame:CGRectMake(0, yOffset+_titleLabel.frame.size.height, self.frame.size
.width, _subtitleLabel.frame.size.height)];
}

@end

Expand Down Expand Up @@ -54,7 +62,7 @@ -(void)setup {

self.titleView = [[RNNTitleView alloc] initWithFrame:navigationBarBounds];
self.titleView.backgroundColor = [UIColor clearColor];
self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
self.titleView.clipsToBounds = YES;

if (self.subtitle) {
Expand Down Expand Up @@ -94,7 +102,7 @@ -(UILabel*)setupSubtitle {
UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
subtitleLabel.textAlignment = NSTextAlignmentCenter;
subtitleLabel.backgroundColor = [UIColor clearColor];
subtitleLabel.autoresizingMask = self.titleView.autoresizingMask;
subtitleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;

NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_subtitleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_subtitleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_subtitleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
[subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle attributes:fontAttributes]];
Expand Down Expand Up @@ -126,7 +134,7 @@ -(UILabel*)setupTitle {
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.backgroundColor = [UIColor clearColor];

titleLabel.autoresizingMask = self.titleView.autoresizingMask;
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;

NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_titleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_titleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_titleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:fontAttributes]];
Expand Down
6 changes: 5 additions & 1 deletion lib/ios/ReactNativeNavigation.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOpt

- (UIWindow *)initializeKeyWindow {
UIWindow* keyWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
keyWindow.backgroundColor = [UIColor whiteColor];
if (@available(iOS 13.0, *)) {
keyWindow.backgroundColor = [UIColor systemBackgroundColor];
} else {
keyWindow.backgroundColor = [UIColor whiteColor];
}
UIApplication.sharedApplication.delegate.window = keyWindow;

return keyWindow;
Expand Down