Commit 5f3af423 authored by 汪洋's avatar 汪洋

优化layoutTitle

parent 19635a20
......@@ -97,7 +97,13 @@
- (void)layoutSubviews {
[super layoutSubviews];
[self layoutTitle];
}
/**
限制标题视图的大小,不会盖住右边的button
*/
- (void)layoutTitle {
if (_nearRightIcon || _nearRightTitle) {
_titleLabel.frame = CGRectMake(80, 0, self.width - 160, 44);
return;
......@@ -165,6 +171,7 @@
_rightIcon = rightIcon;
_rightButton.hidden = NO;
[_rightButton setImage:[UIImage imageNamed:_rightIcon] forState:UIControlStateNormal];
[self layoutTitle];
}
- (void)setLeftTitle:(NSString *)leftTitle {
......@@ -179,12 +186,14 @@
_rightButton.hidden = NO;
[_rightButton setImage:nil forState:UIControlStateNormal];
[_rightButton setTitle:_rightTitle forState:UIControlStateNormal];
[self layoutTitle];
}
- (void)setNearRightIcon:(NSString *)nearRightIcon {
_nearRightIcon = nearRightIcon;
_nearRightButton.hidden = NO;
[_nearRightButton setImage:[UIImage imageNamed:_nearRightIcon] forState:UIControlStateNormal];
[self layoutTitle];
}
- (void)setNearRightTitle:(NSString *)nearRightTitle {
......@@ -192,6 +201,7 @@
_nearRightButton.hidden = NO;
[_nearRightButton setImage:nil forState:UIControlStateNormal];
[_nearRightButton setTitle:_nearRightTitle forState:UIControlStateNormal];
[self layoutTitle];
}
@end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment