我有一个自定义UINavigationBar
,其中在titleView
有两行label
:
UILabel *navBarLabel = [[UILabel alloc] initWithFrame:CGRectZero];
UINavigationItem *item = [[UINavigationItem alloc] init];
navBarLabel.backgroundColor = [UIColor clearColor];
navBarLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
navBarLabel.numberOfLines = 2;
navBarLabel.textAlignment = UITextAlignmentCenter;
navBarLabel.textColor = [UIColor colorWithRed:124.0/255.f green:125.0/255.f blue:128.0/255.f alpha:1.0];
navBarLabel.text = @"This\nis an example";
[navBarLabel sizeToFit];
item.titleView = navBarLabel;
在UIlabel文本中,需要添加两个UILabel,其中一个在另一个的顶部,分别在每行实现定制字体。能否实现?谢谢。