クライアントがiPhoneのデフォルトのフォントを読み取れません。サイズが小さすぎます。ナビゲーションバーを備えたアプリケーションがあり、フォントのサイズなど、その中のすべてを大きくする必要があります。
IBはこれを許可していないようです...何か助けはありますか?
どうもありがとう!
クライアントがiPhoneのデフォルトのフォントを読み取れません。サイズが小さすぎます。ナビゲーションバーを備えたアプリケーションがあり、フォントのサイズなど、その中のすべてを大きくする必要があります。
IBはこれを許可していないようです...何か助けはありますか?
どうもありがとう!
更新:今日(2012年)はカスタムUIの傾向がはるかに大きいため、以下の答えは厳しすぎると思います。高さをカスタマイズするためのサポートされている方法はまだありませんが、UINavigationBarから派生して、いくつかのサイズ設定メソッドをオーバーライドすることはできます。これはおそらくあなたを拒絶することはないでしょう(それはまだ灰色の領域ですが、Appleが今日おそらく見落としているものです)。
必要なサイズを取得したら、iOS 5カスタマイズAPIを使用して、カスタム背景画像を追加できます(WWDC 2011セッション114-UIKitコントロールの外観のカスタマイズを参照)。
2009年からの元の回答:
これは一般的に不可能です。
さらに、ナビゲーションバーの高さを高くすることは、Appleヒューマンインターフェイスガイドラインに違反していると思います。そのため、アプリケーションがAppStoreから拒否される可能性があります。続行する前に、クライアントがこのリスクを理解していることを確認してください。
(拒否のリスクを指摘することは、通常、クライアントに意味のない決定を行わないように説得するための良い方法です。)
ナビゲーションバーでフォントサイズを変更することにした場合は、これを行うことができます(通常はUIViewController
のviewDidLoad
メソッドで)。
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[titleLabel setBackgroundColor:[UIColor clearColor]];
// here's where you can customize the font size
[titleLabel setFont:[UIFont boldSystemFontOfSize:18.0]];
[titleLabel setTextColor:[UIColor whiteColor]];
[titleLabel setText:self.title];
[titleLabel sizeToFit];
[titleLabel setCenter:[self.navigationItem.titleView center]];
[self.navigationItem setTitleView:titleLabel];
[titleLabel release];
サブクラス化することで、それを達成し、iOS3以降をサポートできます。
#import <UIKit/UIKit.h>
@interface ASNavigationBar : UINavigationBar
@property (nonatomic , retain) UIImage *backgroundImage;
@end
そして実装:
#import "ASNavigationBar.h"
@implementation ASNavigationBar
@synthesize backgroundImage = _backgroundImage;
-(void) setBackgroundImage:(UIImage *)backgroundImage
{
if (_backgroundImage != backgroundImage)
{
[_backgroundImage release];
_backgroundImage = [backgroundImage retain];
[self setNeedsDisplay];
}
}
-(void) drawRect:(CGRect)rect
{
// This is how the custom BG image is actually drawn
[self.backgroundImage drawInRect:rect];
}
- (CGSize)sizeThatFits:(CGSize)size
{
// This is how you set the custom size of your UINavigationBar
CGRect frame = [UIScreen mainScreen].applicationFrame;
CGSize newSize = CGSizeMake(frame.size.width , self.backgroundImage.size.height);
return newSize;
}
@end
You should not change the height of the navigation bar. From Apple Programing Guide on View Controller:
Customizing the Navigation Bar Appearance
In a navigation interface, a navigation controller owns its UINavigationBar object and is responsible for managing it. It is not permissible to change the navigation bar object or modify its bounds, frame, or alpha values directly. However, there are a few properties that it is permissible to modify, including the following:
● barStyle property
● translucent property
● tintColor property
(taken from Apple: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/NavigationControllers.html)
UPDATE -- IOS 7 --- still only the available properties can be changed but below is a great tutorial on how to achieve flexibility in the navigation bar http://www.appcoda.com/customize-navigation-status-bar-ios-7/
Skelaの答えに追加するには:
ストーリーボードでナビゲーション コントローラーを開始すると、ストーリーボードの UINavigationBar のクラスをカスタム ナビゲーションバーに変更できます。
次に、クラスで高さの変更を実装します
@interface MyNavigationBar : UINavigationBar
@end
@implementation SwitchAssessmentNavigationBar
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize s = [super sizeThatFits:size];
s.height = 200; // Or some other height
return s;
}
@end