5

クライアントがiPhoneのデフォルトのフォントを読み取れません。サイズが小さすぎます。ナビゲーションバーを備えたアプリケーションがあり、フォントのサイズなど、その中のすべてを大きくする必要があります。

IBはこれを許可していないようです...何か助けはありますか?

どうもありがとう!

4

6 に答える 6

13

更新:今日(2012年)はカスタムUIの傾向がはるかに大きいため、以下の答えは厳しすぎると思います。高さをカスタマイズするためのサポートされている方法はまだありませんが、UINavigationBarから派生して、いくつかのサイズ設定メソッドをオーバーライドすることはできます。これはおそらくあなたを拒絶することはないでしょう(それはまだ灰色の領域ですが、Appleが今日おそらく見落としているものです)。

必要なサイズを取得したら、iOS 5カスタマイズAPIを使用して、カスタム背景画像を追加できます(WWDC 2011セッション114-UIKitコントロールの外観のカスタマイズを参照)。

2009年からの元の回答:

これは一般的に不可能です。

さらに、ナビゲーションバーの高さを高くすることは、Appleヒューマンインターフェイスガイドラインに違反していると思います。そのため、アプリケーションがAppStoreから拒否される可能性があります。続行する前に、クライアントがこのリスクを理解していることを確認してください。

(拒否のリスクを指摘することは、通常、クライアントに意味のない決定を行わないように説得するための良い方法です。)

于 2009-05-21T14:11:18.987 に答える
7

ナビゲーションバーでフォントサイズを変更することにした場合は、これを行うことができます(通常はUIViewControllerviewDidLoadメソッドで)。

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];
于 2009-07-21T20:01:47.020 に答える
5

サブクラス化することで、それを達成し、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

重要な注意事項:

  1. 背景画像に透明な領域がある場合は、barStyleプロパティを「半透明」に設定する必要があります。そうしないと、透明な領域が黒になります。
  2. 44ポイントを超えるNavigationBarがある場合は、BarButtonItemsの位置が正しくない可能性があることを考慮に入れる必要があります。それらはすべてバーの下部に固定されます。layoutSubviewsをオーバーライドし、それらのorigin.y値を変更することで、これを修正できます。
于 2012-03-21T07:55:44.543 に答える
1

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/

于 2013-12-16T07:29:33.573 に答える
0

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
于 2016-05-17T09:39:17.587 に答える