我必须使用标题 View 在导航栏上添加两行不同字体大小的文本。
我试过下面的代码:
我想要大字体的 EREDITOMETRO 和小字体的 LA SUCCESSIONE A PORTATA DI MANO
UILabel * label =[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 480, 44)]; label.backgroundColor =[UIColor clearColor];
label.numberOfLines =2;
label.font =[UIFont boldSystemFontOfSize:9.0f];
label.textColor =[UIColor whiteColor];
label.text = @"EREDITOMETRO \n LA SUCCESSIONE A PORTATA DI MANO";
self.navigationItem.titleView = label;
最佳答案
试试这个 -
NSString *stringName = @"Welcome Home" ;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:stringName];
[attrString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize: 14.0f] range:NSMakeRange(0, 4)];
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 480, 44)];
label.numberOfLines =0;
label.attributedText = attrString;
self.navigationItem.titleView = label;
关于ios - 使用 TitleView 在 IOS 的导航栏上添加 2 行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29469715/