【问题标题】:Is there way to apply customize appearance at once to the whole application?有没有办法一次将自定义外观应用到整个应用程序?
【发布时间】:2012-08-17 07:34:46
【问题描述】:

例如,我有一个方法:

- (void)customizeAppearance
{
[[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:@"Arial-Bold" size:0.0],
        UITextAttributeFont,
        nil]];
}

我怎样才能使这种方法适用于整个应用程序?

【问题讨论】:

    标签: iphone objective-c ios appearance


    【解决方案1】:

    如果您将此代码放在您的应用委托中的 finished lunching 方法中,这将影响所有应用。

    请注意,这仅适用于 iOS 5

    【讨论】:

    【解决方案2】:

    如果你在 UIViewController 中使用它,只需创建你自己的子类 MyUIViewController,你就可以在你创建的每个新屏幕中使用它。只需使用 MyUIViewController 作为屏幕的超类,而不是普通的 UIViewControler。

    一般来说,这是一个好主意,因为您只需更改 MyUIViewController 中的代码即可轻松地将其他行为添加到所有屏幕。

    【讨论】:

      猜你喜欢
      • 2010-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多