I'm trying to replicate an iphone style navbar in my mac app. But I just can't figure out what font (name and size) that the title in the navbar should be. Does anybody know what it is or have a way to figure it out? Thanks in advance.
Update: Here's a picture. I'm referring to the "Navigation bar" pointed out on top. http://www.funkyspacemonkey.com/wp-content/uploads/201开发者_Python百科0/01/iPhone_UI_elements_sizes.jpg
Oh, I just figured it out! Helvetica Neue, as Ben pointed out, and then I used size 20. But then, to complete the look, you need to give it an embossed look. I did this by using this code:
[[myTextField cell] setBackgroundStyle:NSBackgroundStyleLowered];
I found that here: http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/
Now it looks right.
Prior to iPhone 4, the font is Helvetica. The iPhone 4 uses Helvetica Neue.
The point-size you want will depend on what you mean by 'navbar'.
Replicate title label manually:
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];
}
精彩评论