0

我已经能够在属性字符串中使用这些字体描述符。我希望能够在导航栏的标题中使用它们(在 Apple Dev 的旧 DrillDownSave 示例代码中)。我正在努力:

AppDelegate.h

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property(nonatomic, retain) NSDictionary *titleTextAttributes;

AppDelegate.m

@synthesize window, outlineData, navigationController, savedLocation, titleTextAttributes;

- (void)customizeAppearance
{
    [[UINavigationBar appearance] setTitleTextAttributes:
                                  NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor purpleColor],
                                          NSTextEffectAttributeName : NSTextEffectLetterpressStyle,
                                                NSKernAttributeName : @4,
                                      ;
                                            }

我得到“意外的接口名称'NSDictionary':预期的表达式”和“预期的表达式”(似乎与最后一个分号有关)。

4

1 回答 1

0

您在方法调用中声明了一个变量。你应该这样称呼它!

- (void)customizeAppearance
{
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor purpleColor],
                                                               NSTextEffectAttributeName : NSTextEffectLetterpressStyle,
                                                                     NSKernAttributeName : @4}];

}

更新:

您可以在您的应用程序委托中调用它-application:didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self customizeAppearance];
    return YES;
}
于 2013-10-15T17:48:04.867 回答