fix
This commit is contained in:
@@ -10,4 +10,8 @@
|
||||
|
||||
@interface GiGaNavTitileView : UIView
|
||||
- (id)initWithString:(NSString *)str frame:(CGRect)frame;
|
||||
@property(nonatomic,copy) NSString *titleStr;
|
||||
@property(nonatomic,strong) UILabel *navlabel;
|
||||
@property(nonatomic,strong) UIColor *titleColor;
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,20 +9,45 @@
|
||||
#import "GiGaNavTitileView.h"
|
||||
|
||||
@implementation GiGaNavTitileView
|
||||
|
||||
@synthesize titleStr = _titleStr;
|
||||
@synthesize titleColor = _titleColor;
|
||||
- (id)initWithString:(NSString *)str frame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 44)];
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.text = str;
|
||||
label.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18.f];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:label];
|
||||
self.titleStr = str;
|
||||
[self creatTitle:frame];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self creatTitle:frame];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)creatTitle:(CGRect)frame{
|
||||
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 44)];
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.text = self.titleStr;
|
||||
label.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18.f];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:label];
|
||||
self.navlabel = label;
|
||||
|
||||
}
|
||||
|
||||
- (void)setTitleStr:(NSString *)titleStr{
|
||||
|
||||
_titleStr = titleStr;
|
||||
|
||||
self.navlabel.text = titleStr;
|
||||
}
|
||||
|
||||
-(void)setTitleColor:(UIColor *)titleColor{
|
||||
_titleColor = titleColor;
|
||||
self.navlabel.textColor = _titleColor;
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user