Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios uibarbuttonite样式普通更改字体_Ios_Cocoa Touch_Ios6_Uibarbuttonitem_Uibarbuttonitemstyle - Fatal编程技术网

Ios uibarbuttonite样式普通更改字体

Ios uibarbuttonite样式普通更改字体,ios,cocoa-touch,ios6,uibarbuttonitem,uibarbuttonitemstyle,Ios,Cocoa Touch,Ios6,Uibarbuttonitem,Uibarbuttonitemstyle,改变 NSDictionary * barButtonAppearanceDict = @{UITextAttributeFont : font}; [[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal]; 当使用普通时不会影响uibarbuttonite 如何更改普通样式UIBarButtonItem的字体 这仍然适用于iOS

改变

NSDictionary * barButtonAppearanceDict = @{UITextAttributeFont : font};
    [[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal];
当使用普通时不会影响uibarbuttonite

如何更改普通样式UIBarButtonItem的字体

这仍然适用于iOS6

这对我来说很有效,但是(使用纯巴布托尼姆),我刚刚测试过它:

[self.myBarButtonItem setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIFont fontWithName:@"Helvetica" size:22.0],NSFontAttributeName,
  nil]forState:UIControlStateNormal];
要使用外观代理,可以尝试以下方法:

 NSDictionary *attrDict = [NSDictionary dictionaryWithObject: [UIFont fontWithName:@"Helvetica" size:22.0] forKey: UITextAttributeFont];

[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
                                        forState: UIControlStateDisabled];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
                                        forState: UIControlStateNormal];
您确定在
AppDelegate
-类中实现了这一点吗?(例如,在
didfishlaunchingwithoptions
-method)

中,这对我来说是有效的,但是(使用纯巴布通体),我刚刚测试了它:

[self.myBarButtonItem setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIFont fontWithName:@"Helvetica" size:22.0],NSFontAttributeName,
  nil]forState:UIControlStateNormal];
要使用外观代理,可以尝试以下方法:

 NSDictionary *attrDict = [NSDictionary dictionaryWithObject: [UIFont fontWithName:@"Helvetica" size:22.0] forKey: UITextAttributeFont];

[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
                                        forState: UIControlStateDisabled];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
                                        forState: UIControlStateNormal];

您确定在
AppDelegate
-类中实现了这一点吗?(例如,在
didfishlaunchingwithoptions
-method)

中,我在appdelegate中设置了以下内容,效果非常好:

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

    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Avenir" size:21.0]} forState:UIControlStateNormal];

}

我在appdelegate中设置了以下内容,效果非常好:

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

    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Avenir" size:21.0]} forState:UIControlStateNormal];

}

确实将NSFontAttributeName与[UIBarButtonItem外观]一起使用,但似乎不起作用ID将NSFontAttributeName与[UIBarButtonItem外观]一起使用,但似乎不起作用