Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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
Objective c 如何在ios dev中更改默认字体_Objective C_Ios_Cocoa_Ios5 - Fatal编程技术网

Objective c 如何在ios dev中更改默认字体

Objective c 如何在ios dev中更改默认字体,objective-c,ios,cocoa,ios5,Objective C,Ios,Cocoa,Ios5,通过谷歌搜索,现在我可以使用自定义字体了。像这样: [loginButton.titleLabel setFont:[UIFont fontWithName:@"OpenSans-Bold" size:15]]; -(UIFont *)getFont { UIFont *font = [UIFont fontWithName:@"OpenSans-Bold" size:15]; return font; } 您不能在界面构建中选择自定义字体,因此需要反复编写代码 我的问题是:

通过谷歌搜索,现在我可以使用自定义字体了。像这样:

[loginButton.titleLabel setFont:[UIFont fontWithName:@"OpenSans-Bold" size:15]];
-(UIFont *)getFont
{
    UIFont *font = [UIFont fontWithName:@"OpenSans-Bold" size:15];
    return font;
}
您不能在界面构建中选择自定义字体,因此需要反复编写代码


我的问题是:如何将应用程序默认字体更改为自定义字体(我不会更改系统字体=)

最好的方法是创建一个函数,该函数将返回您希望的字体,如下所示:

[loginButton.titleLabel setFont:[UIFont fontWithName:@"OpenSans-Bold" size:15]];
-(UIFont *)getFont
{
    UIFont *font = [UIFont fontWithName:@"OpenSans-Bold" size:15];
    return font;
}
然后,无论你在哪里需要这种字体,你都可以这样做(以你的按钮为例)


这个帖子很模糊。请更详细地解释你想做什么,或者提供一些代码。我自己问了这个问题,我发现这是一个有效的问题,答案也很好@allenwei:你应该把它当作正确的答案来接受。可能重复一次又一次的打字很无聊。此外,我不能在interface builder中使用自定义字体。我认为这是您的最佳选择。更好的方法是这样做“#定义字体_CUSTOME[UIFontWithName:@“此处自定义字体名称”大小:此处大小]”