|
@@ -6,6 +6,14 @@
|
6
|
6
|
|
7
|
7
|
@implementation RNNTitleView
|
8
|
8
|
|
|
9
|
+- (void)layoutSubviews {
|
|
10
|
+ CGFloat heightSum = _titleLabel.frame.size.height + _subtitleLabel.frame.size.height;
|
|
11
|
+ CGFloat yOffset = (self.frame.size.height - heightSum) / 2;
|
|
12
|
+
|
|
13
|
+ [_titleLabel setFrame:CGRectMake(0, yOffset, self.frame.size.width, _titleLabel.frame.size.height)];
|
|
14
|
+ [_subtitleLabel setFrame:CGRectMake(0, yOffset+_titleLabel.frame.size.height, self.frame.size
|
|
15
|
+ .width, _subtitleLabel.frame.size.height)];
|
|
16
|
+}
|
9
|
17
|
|
10
|
18
|
@end
|
11
|
19
|
|
|
@@ -54,7 +62,7 @@
|
54
|
62
|
|
55
|
63
|
self.titleView = [[RNNTitleView alloc] initWithFrame:navigationBarBounds];
|
56
|
64
|
self.titleView.backgroundColor = [UIColor clearColor];
|
57
|
|
- self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
|
|
65
|
+ self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
|
58
|
66
|
self.titleView.clipsToBounds = YES;
|
59
|
67
|
|
60
|
68
|
if (self.subtitle) {
|
|
@@ -94,7 +102,7 @@
|
94
|
102
|
UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
|
95
|
103
|
subtitleLabel.textAlignment = NSTextAlignmentCenter;
|
96
|
104
|
subtitleLabel.backgroundColor = [UIColor clearColor];
|
97
|
|
- subtitleLabel.autoresizingMask = self.titleView.autoresizingMask;
|
|
105
|
+ subtitleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
98
|
106
|
|
99
|
107
|
NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_subtitleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_subtitleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_subtitleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
|
100
|
108
|
[subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle attributes:fontAttributes]];
|
|
@@ -126,7 +134,7 @@
|
126
|
134
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
127
|
135
|
titleLabel.backgroundColor = [UIColor clearColor];
|
128
|
136
|
|
129
|
|
- titleLabel.autoresizingMask = self.titleView.autoresizingMask;
|
|
137
|
+ titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
130
|
138
|
|
131
|
139
|
NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_titleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_titleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_titleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
|
132
|
140
|
[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:fontAttributes]];
|