【问题标题】:iPhone Nav Bar FontiPhone 导航栏字体
【发布时间】:2011-10-06 21:46:00
【问题描述】:

我正在尝试在我的 mac 应用程序中复制 iphone 风格的导航栏。但我只是无法弄清楚导航栏中的标题应该是什么字体(名称和大小)。有人知道它是什么或有办法弄清楚吗?提前致谢。

更新:这是一张图片。我指的是顶部指出的“导航栏”。 http://www.funkyspacemonkey.com/wp-content/uploads/2010/01/iPhone_UI_elements_sizes.jpg

【问题讨论】:

  • 你能链接到你所说的那种 iPhone 导航栏的屏幕截图吗?

标签: iphone cocoa-touch fonts uinavigationbar font-size


【解决方案1】:

手动复制标题标签:

UINavigationItem(Category)

- (void)setTitle:(NSString *)title
{
    UIFont* font = [UIFont fontWithName:@"HelveticaNeue-Bold"  size:20.0f];
    CGSize textSize = [title sizeWithFont:font];
    UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
    label.textColor =[UIColor whiteColor];
    label.backgroundColor = [UIColor clearColor]; 
    label.text = title;
    label.font = font;
    label.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5f];
    label.shadowOffset = CGSizeMake(0,-1);
    label.textAlignment = UITextAlignmentCenter;
    [self setTitleView:label];
    [label release];
}

【讨论】:

    【解决方案2】:

    哦,我刚刚想通了!正如 Ben 指出的那样,Helvetica Neue,然后我使用了 20 号。但是,为了完成外观,你需要给它一个浮雕外观。我通过使用以下代码做到了这一点:

    [[myTextField cell] setBackgroundStyle:NSBackgroundStyleLowered];
    

    我在这里找到了:http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/

    现在看起来不错。

    【讨论】:

      【解决方案3】:

      在 iPhone 4 之前,字体是 Helvetica。 iPhone 4 使用 Helvetica Neue。
      您想要的磅值取决于您所说的“导航栏”的含义。

      【讨论】:

      • 我试过 Helvetica Neue,但它看起来不正确。我尝试了几种不同的字体大小都无济于事。我已经链接了一张图片来澄清我在说什么,所以也许你可以看看。
      • 试试 Helvetica Neue Bold - 绝对是这样。我有一把小提琴,它看起来差不多。在您链接导航栏上的“标题”一词的图像上,字体大小约为 24。
      • 仍然不适合我。这是我的字体和大小的图片:link
      猜你喜欢
      • 2020-02-22
      • 1970-01-01
      • 2018-02-13
      • 2011-08-15
      • 1970-01-01
      • 1970-01-01
      • 2014-07-21
      • 2012-03-26
      • 1970-01-01
      相关资源
      最近更新 更多