归属标题未在UIButton中加载自定义字体xib文件

时间:2015-05-08 20:46:14

标签: ios interface-builder nsattributedstring

我在这个问题上摸不着头脑,无法弄清楚是什么问题。我的一个界面构建器xib中有一个按钮,它有一个标题的属性字符串,它使用添加到我的应用程序的自定义字体。界面构建器中的一切看起来都很好。

我100%确信我已将字体(蒙特塞拉特)正确加载到我的应用中。我可以在整个代码和非属性控件的标题中正确使用它,它工作正常。我还检查了调试器并正确列出了字体:

(lldb) po [UIFont familyNames]

<__NSCFArray 0x7bb34e20>(
Thonburi,
...
Montserrat,
...
Bodoni 72 Smallcaps
)

(lldb) po [UIFont fontNamesForFamilyName:@"Montserrat"]

<__NSCFArray 0x7be75400>(
Montserrat-Regular,
Montserrat-Bold
)

我也可以在文本编辑器的xib文件中看到它看起来应该加载蒙特塞拉特的单词&#34;得到&#34;:

                        <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取代了我对&#34; Montserrat-Bold&#34;的使用。与&#34; HelveticaNeueInterface-Regular&#34;在&#34;得到&#34;。以下是调试器的另一个摘录:

(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上。但我可以使用蒙特塞拉特就非属性标题。我在这一点上真的很难过。有人遇到过这个问题吗?

谢谢,   欧米

1 个答案:

答案 0 :(得分:1)

我认为这是一个错误

遇到了这个雷达http://openradar.appspot.com/18716979