归因文本未在模拟器设备中显示

时间:2015-07-28 18:58:06

标签: ios xcode

我正在使用属性文本来编辑文本中的字符串样式。在故事板中,它显示我想要的。但是当我尝试将应用程序运行到模拟器设备时,看看结果是否正常但是属性文本没有显示。模拟器设备仅显示纯文本。如何让仿真器设备显示属性文本?

<!--View Controller-->
        <scene sceneID="Hfg-vx-s6i">
            <objects>
                <viewController id="di3-Y9-W12" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="F6t-h3-SiZ"/>
                        <viewControllerLayoutGuide type="bottom" id="axk-bq-fyl"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="ph9-HP-KWx">
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pNn-mb-lpY">
                                <rect key="frame" x="0.0" y="0.0" width="240" height="128"/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <attributedString key="attributedText">
                                    <fragment content="This is test and this suppose to be bold.">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue-Bold"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                    <fragment content="
    
    ">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                    <fragment content="This is test and this suppose to be italic.">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue-Italic"/>
                                            <font key="NSOriginalFont" size="14" name="HelveticaNeue-Italic"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                    <fragment content="
    
    ">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                    <fragment content="This is test and this suppose to be regular.">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue"/>
                                            <font key="NSOriginalFont" size="14" name="HelveticaNeue"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                    <fragment content="
    
    Test Test Test">
                                        <attributes>
                                            <font key="NSFont" size="14" name="HelveticaNeue"/>
                                            <paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                        </attributes>
                                    </fragment>
                                </attributedString>
                                <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
                                <variation key="heightClass=regular-widthClass=compact" fixedFrame="YES">
                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                    <rect key="frame" x="0.0" y="0.0" width="400" height="800"/>
                                </variation>
                            </textView>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                        <variation key="default">
                            <mask key="subviews">
                                <exclude reference="pNn-mb-lpY"/>
                            </mask>
                        </variation>
                        <variation key="heightClass=regular-widthClass=compact">
                            <mask key="subviews">
                                <include reference="pNn-mb-lpY"/>
                            </mask>
                        </variation>
                    </view>
                </viewController>

1 个答案:

答案 0 :(得分:0)

我不知道这是否是该问题的解决方案,但我取消选中文件检查器中的大小类,并且所有设备都能够显示属性文本。我不知道为什么会这样,但它正在发挥作用。

enter image description here

感谢您尝试解决此问题。