0

アプリに次のグローバル形式を適用しています:

-(void)customizeAppearance{

    //Customizing UINavigationBar
    UIImage *navigationbarImage44 = [[UIImage imageNamed:@"navigationbar_44"]
                                resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    UIImage *navigationbarImage32 = [[UIImage imageNamed:@"navigationbar_32"]
                                resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];

    //Set the background image for *all* UINavigationBars
    [[UINavigationBar appearance] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setBackgroundImage:navigationbarImage32 forBarMetrics:UIBarMetricsLandscapePhone];

    //Customize the titlebar for *all* the navigationBars
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                          [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],  UITextAttributeTextColor,
                                                          [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],  UITextAttributeTextShadowColor,
                                                          [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],          UITextAttributeTextShadowOffset,
                                                          [UIFont fontWithName:labelFontName size:0.0],             UITextAttributeFont,
                                                          nil]];




    //Customizing UIToolbar
    UIImage *toolbarImage44 = [[UIImage imageNamed:@"toolbar_44"]
                                     resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    UIImage *toolbarImage32 = [[UIImage imageNamed:@"toolbar_32"]
                                     resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];

    [[UIToolbar appearance] setBackgroundImage:toolbarImage44 forToolbarPosition:UIToolbarPositionAny
                                    barMetrics:UIBarMetricsDefault];
    [[UIToolbar appearance] setBackgroundImage:toolbarImage32 forToolbarPosition:UIToolbarPositionAny
                                    barMetrics:UIBarMetricsLandscapePhone];

    //Customizing UIBarButtonItem
    UIImage *button30 = [[UIImage imageNamed:@"buttonitem_30"]
                         resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
    UIImage *button24 = [[UIImage imageNamed:@"buttonitem_24"]
                         resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];


    [[UIBarButtonItem appearance] setBackgroundImage:button30 forState:UIControlStateNormal
                                          barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:button24 forState:UIControlStateNormal
                                          barMetrics:UIBarMetricsLandscapePhone];


    //Customizing UIBarButtonItem BackButton
    [[UIBarButtonItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],  UITextAttributeTextColor,
      [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],  UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)],           UITextAttributeTextShadowOffset,
      [UIFont fontWithName:labelFontName size:0.0],     UITextAttributeFont,
      nil]forState:UIControlStateNormal];


    UIImage *buttonBack30 = [[UIImage imageNamed:@"backbuttonitem_30"]
                             resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
    UIImage *buttonBack24 = [[UIImage imageNamed:@"backbuttonitem_24"]
                             resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30
                                                      forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24
                                                      forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];


    //Customizing UISegmentedControl
    [[UISegmentedControl appearance] setTintColor:(UIColorFromRGB(toolbarTintColor))];

    //Customizing UISearchBar
    [[UISearchBar appearance] setBackgroundImage:navigationbarImage44];
}

これを AppDelegate.m メソッドで呼び出しています

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

    [self customizeAppearance];
    return YES;
}

質問は:

viewController が iPad ポップアップ内にない場合、この一般的な形式をすべて調整するにはどうすればよいですか?ここに画像の説明を入力

ポップアップで元の形式を共有したくありません。いつものように、UINavigationBars、UIToolbars、UIBarButtonItems .. を黒色にしてください。

サポートを事前に感謝します

4

1 に答える 1

0

を使用する代わりに、 を使用appearanceできますappearanceWhenContainedIn:。だから代わりに

[[UINavigationBar appearance] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];

行う

[[UINavigationBar appearanceWhenContainedIn:[CustomViewController class]] setBackgroundImage:navigationbarImage44 forBarMetrics:UIBarMetricsDefault];

これにより、外観の変更が にUINavigationBar含まれるインスタンスのみに制限されCustomViewControllerます。などの使用方法を明確にするために、この質問を確認することをお勧めします。appearanceWhenContainedInUIBarButtonItem

于 2013-09-24T02:44:06.277 に答える