【问题标题】:Custom navigation bar minimum font scale?自定义导航栏最小字体比例?
【发布时间】:2013-09-13 09:28:42
【问题描述】:

我需要在导航栏上设置最小字体比例。我在 AppDelegate.m 中设置了标题属性:

[[UINavigationBar appearance] setTitleTextAttributes: @{
                            UITextAttributeTextColor: [UIColor colorWithRed:54/255.0f green:54/255.0f blue:54/255.0f alpha:1.0f],
                     UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 0.0f)],
                                 UITextAttributeFont: [UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0f]
 }];

我的导航栏被拖放到故事板中的 UIView 上。一切都适用于自定义导航栏图像和文本属性,但如果可能的话,我需要设置最小字体比例。

【问题讨论】:

    标签: ios xcode uinavigationbar customization title


    【解决方案1】:

    我通过创建标签并用作导航栏标题来解决它。

    // NavBar title
    UILabel *customNavBarTitle = [[UILabel alloc] initWithFrame:CGRectMake(44, 0, 320, 44)];
    customNavBarTitle.textAlignment = NSTextAlignmentCenter;
    customNavBarTitle.adjustsFontSizeToFitWidth = YES;
    [customNavBarTitle setFont:[UIFont fontWithName:@"OpenSans-Semibold" size:15.0f]];
    [customNavBarTitle setBackgroundColor:[UIColor clearColor]];
    [customNavBarTitle setTextColor:[UIColor blackColor];
    [customNavBarTitle setText:customTitle];
    [self.view addSubview:customNavBarTitle];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 2012-03-26
      • 1970-01-01
      相关资源
      最近更新 更多