lianlianbushell 2013-01-30 03:13 采纳率: 0%
浏览 3136

UINavigationBar添加2个UILabel

我有一个自定义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,其中一个在另一个的顶部,分别在每行实现定制字体。能否实现?谢谢。

  • 写回答

1条回答 默认 最新

  • 睡觉不盖被 2015-08-24 15:42
    关注

    楼主可以试试这样 将这两个UILabel添加至一个新的UIView中 ,然后将UIView 添加至titleView中,如果移除的话 只需要移除这个UIView

    评论

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作