Skip to content

Commit

Permalink
Fix title.font when subtitle supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd committed Dec 9, 2018
1 parent b40f8ed commit 14a5b74
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/ios/RNNTitleViewHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,10 @@ -(UILabel*)setupTitle {

titleLabel.autoresizingMask = self.titleView.autoresizingMask;

UIFont *titleFont = [UIFont boldSystemFontOfSize:17.f];
NSDictionary* fontAttributes = [RNNFontAttributesCreator createFontAttributesWithFontFamily:[_titleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_titleOptions.fontSize getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];

This comment has been minimized.

Copy link
@pkyeck

pkyeck Dec 16, 2018

why do you use color:[_subtitleOptions.color getWithDefaultValue:nil]? shouldn't it be _titleOptions.color?

[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:fontAttributes]];

CGFloat fontSizeFloat = [RCTConvert CGFloat:[_titleOptions.fontSize getWithDefaultValue:@(17)]];
titleFont = [UIFont boldSystemFontOfSize:fontSizeFloat];

[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:_titleOptions.fontAttributes]];

CGSize labelSize = [titleLabel.text sizeWithAttributes:@{NSFontAttributeName:titleFont}];
CGSize labelSize = [titleLabel.text sizeWithAttributes:fontAttributes];
CGRect labelframe = titleLabel.frame;
labelframe.size = labelSize;
titleLabel.frame = labelframe;
Expand Down

2 comments on commit 14a5b74

@pkyeck
Copy link

@pkyeck pkyeck commented on 14a5b74 Dec 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and while you're at it, couldn't you just delete these lines?

if (_titleOptions.color.hasValue) {
UIColor *color = _titleOptions.color.get;
titleLabel.textColor = color;

Color is set in line 130 - which makes this redundant.

@pkyeck
Copy link

@pkyeck pkyeck commented on 14a5b74 Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yogevbd did you see my comments here?

Please sign in to comment.