|
|
|
|
6
|
|
6
|
|
7
|
@implementation RNNTitleView
|
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
|
@end
|
18
|
@end
|
11
|
|
19
|
|
|
|
|
|
54
|
|
62
|
|
55
|
self.titleView = [[RNNTitleView alloc] initWithFrame:navigationBarBounds];
|
63
|
self.titleView = [[RNNTitleView alloc] initWithFrame:navigationBarBounds];
|
56
|
self.titleView.backgroundColor = [UIColor clearColor];
|
64
|
self.titleView.backgroundColor = [UIColor clearColor];
|
57
|
- self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
|
|
|
|
|
65
|
+ self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
|
58
|
self.titleView.clipsToBounds = YES;
|
66
|
self.titleView.clipsToBounds = YES;
|
59
|
|
67
|
|
60
|
if (self.subtitle) {
|
68
|
if (self.subtitle) {
|
|
|
|
|
94
|
UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
|
102
|
UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
|
95
|
subtitleLabel.textAlignment = NSTextAlignmentCenter;
|
103
|
subtitleLabel.textAlignment = NSTextAlignmentCenter;
|
96
|
subtitleLabel.backgroundColor = [UIColor clearColor];
|
104
|
subtitleLabel.backgroundColor = [UIColor clearColor];
|
97
|
- subtitleLabel.autoresizingMask = self.titleView.autoresizingMask;
|
|
|
|
|
105
|
+ subtitleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
98
|
|
106
|
|
99
|
NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_subtitleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_subtitleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_subtitleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
|
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
|
[subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle attributes:fontAttributes]];
|
108
|
[subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle attributes:fontAttributes]];
|
|
|
|
|
126
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
134
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
127
|
titleLabel.backgroundColor = [UIColor clearColor];
|
135
|
titleLabel.backgroundColor = [UIColor clearColor];
|
128
|
|
136
|
|
129
|
- titleLabel.autoresizingMask = self.titleView.autoresizingMask;
|
|
|
|
|
137
|
+ titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
130
|
|
138
|
|
131
|
NSDictionary* fontAttributes = [RNNFontAttributesCreator createWithFontFamily:[_titleOptions.fontFamily getWithDefaultValue:nil] fontSize:[_titleOptions.fontSize getWithDefaultValue:nil] fontWeight:[_titleOptions.fontWeight getWithDefaultValue:nil] color:[_subtitleOptions.color getWithDefaultValue:nil]];
|
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
|
[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:fontAttributes]];
|
140
|
[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:fontAttributes]];
|