Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/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
iPhone:字体不影响用户界面_Iphone_User Interface_Uifont - Fatal编程技术网

iPhone:字体不影响用户界面

iPhone:字体不影响用户界面,iphone,user-interface,uifont,Iphone,User Interface,Uifont,我在我的应用程序中使用Constantia字体系列,常规粗体和斜体是我的要求,我面临的问题是,我只能得到常规样式的输出,而不能得到粗体和斜体,我已经在应用程序中添加了所有三种样式的字体,并在应用程序提供的字体部分的plist文件中。我试着用下面的方法 UIFont *bFont = [UIFont fontWithName:@"Constantia-Bold" size:24.0]; UIFont *bFont = [UIFont fontWithName:@"ConstantiaBold" s

我在我的应用程序中使用Constantia字体系列,
常规
粗体和斜体是我的要求,我面临的问题是,我只能得到常规样式的输出,而不能得到粗体和斜体,我已经在应用程序中添加了所有三种样式的字体,并在应用程序提供的字体部分的plist文件中。我试着用下面的方法

UIFont *bFont = [UIFont fontWithName:@"Constantia-Bold" size:24.0];
UIFont *bFont = [UIFont fontWithName:@"ConstantiaBold" size:24.0];
UIFont *bFont = [UIFont fontWithName:@"Constantia_Bold" size:24.0];

UIFont *iFont = [UIFont fontWithName:@"Constantia-Italic" size:24.0];
UIFont *iFont = [UIFont fontWithName:@"ConstantiaItalic" size:24.0];
UIFont *iFont = [UIFont fontWithName:@"Constantia_Italic" size:24.0];
但没有一个案例有效,只有
UIFont*font=[UIFont-fontWithName:@“Constantia”大小:24.0]正在工作。我知道我只在字体名称上遗漏了一些东西

我尝试在Mac字体的选项中查找字体,我在
所有字体
部分(左上)下找到了这种字体,我发现一个奇怪的是,所有
康斯坦蒂亚
粗体、斜体和
普通
都是作为一个单独的名称安装的,即只安装
康斯坦蒂亚


附加字体可从下载。

这是如何在应用程序中添加自定义字体的步骤

1-在应用程序中添加
.TTF
字体
2-修改
application-info.plist文件

3-将键“应用程序提供的字体”添加到新行
4-并将每个
.TTF
文件(字体)添加到每行

欲了解更多信息,请阅读和访问网站

用于加粗

// Equivalent to [UIFont fontWithName:@"FontName-BoldMT" size:17]
UIFont* font = [UIFont fontWithFamilyName:@"FontName" traits:GSBoldFontMask size:17];
和粗体/斜体

UIFont* font = [UIFont fontWithMarkupDescription:@"font-family: FontName; font-size: 17px; font-weight: bold/italic;"]; // set here, either bold/italic.

这是如何在应用程序中添加自定义字体的步骤

1-在应用程序中添加
.TTF
字体
2-修改
application-info.plist文件

3-将键“应用程序提供的字体”添加到新行
4-并将每个
.TTF
文件(字体)添加到每行

欲了解更多信息,请阅读和访问网站

用于加粗

// Equivalent to [UIFont fontWithName:@"FontName-BoldMT" size:17]
UIFont* font = [UIFont fontWithFamilyName:@"FontName" traits:GSBoldFontMask size:17];
和粗体/斜体

UIFont* font = [UIFont fontWithMarkupDescription:@"font-family: FontName; font-size: 17px; font-weight: bold/italic;"]; // set here, either bold/italic.

以下是您如何查看应用程序可使用的每种字体的真实名称:

// Log fonts
for (NSString *family in [UIFont familyNames])
{
    NSLog(@"Font family %@:", family);
    for (NSString *font in [UIFont fontNamesForFamilyName:family])
        NSLog("    %@", font);
}

以下是您如何查看应用程序可使用的每种字体的真实名称:

// Log fonts
for (NSString *family in [UIFont familyNames])
{
    NSLog(@"Font family %@:", family);
    for (NSString *font in [UIFont fontNamesForFamilyName:family])
        NSLog("    %@", font);
}

我认为IOS中不存在这种字体。请从此处查看
http://iosfonts.com/

我认为IOS中不存在这种字体。请从此处查看
http://iosfonts.com/

2018年6月16日更新:申请可能被拒绝,请尝试寻找其他解决方案

 #import <dlfcn.h>

// includer for font
NSUInteger loadFonts( )
{
    NSUInteger newFontCount = 0;
    NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
    const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];

    if (frameworkPath) 
    {
        void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);

        if (graphicsServices)
        {
            BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile");

            if (GSFontAddFromFile)
            {

                BOOL verizon = NO;

                NSLog(@"%@",[[UIDevice currentDevice] machine]);

                if ([[[UIDevice currentDevice] machine] rangeOfString:@"iPhone3,3"].location != NSNotFound) {
                    verizon = YES;
                }

                for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
                {
                    if ([fontFile rangeOfString:@"_"].location != NSNotFound && verizon) {
                        newFontCount += GSFontAddFromFile([fontFile UTF8String]);
                    }

                    if ([fontFile rangeOfString:@"-"].location != NSNotFound && !verizon) {
                        newFontCount += GSFontAddFromFile([fontFile UTF8String]);
                    }

                }
            }
        }
    }

    return newFontCount;
}
#导入
//字体包含器
NSU整数加载字体()
{
NSU整数newFontCount=0;
NSBundle*frameworkBundle=[NSBundle BundleWithiIdentifier:@“com.apple.GraphicsServices”];
const char*frameworkPath=[[frameworkBundle executablePath]UTF8String];
if(框架路径)
{
void*graphicsServices=dlopen(框架路径,RTLD_-NOLOAD | RTLD_-LAZY);
if(图形服务)
{
BOOL(*GSFontAddFromFile)(const char*)=dlsym(graphicsServices,“GSFontAddFromFile”);
if(GSFontAddFromFile)
{
布尔威瑞森=否;
NSLog(@“%@,[[UIDevice currentDevice]机器]);
if([[[UIDevice currentDevice]machine]rangeOfString:@“iPhone3,3”].位置!=NSNotFound){
verizon=是;
}
对于(位于[[NSBundle mainBundle]路径中的NSString*fontFile ForResourceSoftType:@“ttf”目录:nil])
{
if([fontFile rangeOfString:@“"”].location!=NSNotFound&&verizon){
newFontCount+=GSFontAddFromFile([fontFile UTF8String]);
}
if([fontFile rangeOfString:@“-“].location!=NSNotFound&&!verizon){
newFontCount+=GSFontAddFromFile([fontFile UTF8String]);
}
}
}
}
}
返回newFontCount;
}

我通常使用该功能:)

2018年6月16日更新:申请可能被拒绝,请尝试寻找其他解决方案

 #import <dlfcn.h>

// includer for font
NSUInteger loadFonts( )
{
    NSUInteger newFontCount = 0;
    NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
    const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];

    if (frameworkPath) 
    {
        void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);

        if (graphicsServices)
        {
            BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile");

            if (GSFontAddFromFile)
            {

                BOOL verizon = NO;

                NSLog(@"%@",[[UIDevice currentDevice] machine]);

                if ([[[UIDevice currentDevice] machine] rangeOfString:@"iPhone3,3"].location != NSNotFound) {
                    verizon = YES;
                }

                for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
                {
                    if ([fontFile rangeOfString:@"_"].location != NSNotFound && verizon) {
                        newFontCount += GSFontAddFromFile([fontFile UTF8String]);
                    }

                    if ([fontFile rangeOfString:@"-"].location != NSNotFound && !verizon) {
                        newFontCount += GSFontAddFromFile([fontFile UTF8String]);
                    }

                }
            }
        }
    }

    return newFontCount;
}
#导入
//字体包含器
NSU整数加载字体()
{
NSU整数newFontCount=0;
NSBundle*frameworkBundle=[NSBundle BundleWithiIdentifier:@“com.apple.GraphicsServices”];
const char*frameworkPath=[[frameworkBundle executablePath]UTF8String];
if(框架路径)
{
void*graphicsServices=dlopen(框架路径,RTLD_-NOLOAD | RTLD_-LAZY);
if(图形服务)
{
BOOL(*GSFontAddFromFile)(const char*)=dlsym(graphicsServices,“GSFontAddFromFile”);
if(GSFontAddFromFile)
{
布尔威瑞森=否;
NSLog(@“%@,[[UIDevice currentDevice]机器]);
if([[[UIDevice currentDevice]machine]rangeOfString:@“iPhone3,3”].位置!=NSNotFound){
verizon=是;
}
对于(位于[[NSBundle mainBundle]路径中的NSString*fontFile ForResourceSoftType:@“ttf”目录:nil])
{
if([fontFile rangeOfString:@“"”].location!=NSNotFound&&verizon){
newFontCount+=GSFontAddFromFile([fontFile UTF8String]);
}
if([fontFile rangeOfString:@“-“].location!=NSNotFound&&!verizon){
newFontCount+=GSFontAddFromFile([fontFile UTF8String]);
}
}
}
}
}
返回newFontCount;
}

我通常使用以下功能:)

谢谢您的快速回复!正如我在问题中提到的,我知道如何将自定义字体添加到应用程序中,我还能够使用
Contantia
常规字体,但只有粗体和斜体字体有问题。如果你有时间的话,我已经用字体源url编辑了我的问题。
GSBoldFontMask
type和
fontWithMarkupDescription
method是
UIFont
class方法吗?我从google for u找到了它,但我不确定它是否有效。试试看:)谢谢你的快速回复!正如我在问题中提到的,我是