Я ломаю голову над этой проблемой и не могу понять, что не так. У меня есть кнопка в одном из моих xib-файлов конструктора интерфейсов, у которой есть атрибутированная строка для заголовка, в котором используется пользовательский шрифт, добавленный в мое приложение. В конструкторе интерфейсов все выглядит нормально.
Я на 100% уверен, что правильно загрузил шрифт (Montserrat) в свое приложение. Я могу правильно использовать его во всем коде и в неатрибутированных заголовках элементов управления, и он отлично работает. Я также проверил в отладчике, и шрифт указан правильно:
(lldb) po [UIFont familyNames]
<__NSCFArray 0x7bb34e20>(
Thonburi,
...
Montserrat,
...
Bodoni 72 Smallcaps
)
(lldb) po [UIFont fontNamesForFamilyName:@"Montserrat"]
<__NSCFArray 0x7be75400>(
Montserrat-Regular,
Montserrat-Bold
)
Я также вижу в файле xib в текстовом редакторе, похоже, он должен загрузить Монтсеррат для слова «получил»:
<state key="normal">
<attributedString key="attributedTitle">
<fragment content="Already ">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="15" name="Helvetica"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content="got">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="15" name="Montserrat-Bold"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content=" an account? ">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="15" name="Helvetica"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content="SIGN IN!">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="15" name="Helvetica-Bold"/>
<font key="NSOriginalFont" size="15" name="Helvetica-Bold"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
</state>
Но я вижу, что iOS заменила мое использование «Montserrat-Bold» на «HelveticaNeueInterface-Regular» в слове «получил». Вот еще одна выдержка из отладчика:
(lldb) po [self signInButton].titleLabel.attributedText
Already {
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb41430> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}got{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb3ffe0> font-family: \".HelveticaNeueInterface-Regular\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
} an account? {
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb41430> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}SIGN IN!{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb3f6a0> font-family: \"Helvetica\"; font-weight: bold; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}
Та же проблема, кажется, возникает на UILabels, симуляторе или устройстве, iOS 7 или 8. Но я могу прекрасно использовать Montserrat для названия без атрибута. Я действительно в тупике в этот момент. Кто-нибудь когда-нибудь сталкивался с этой проблемой?
Спасибо, Омри.