繁体   English   中英

属性文本不在模拟器设备中显示

[英]Attributed text not displaying in emulator device

我正在使用属性文本来编辑文本中的字符串样式。 在情节提要中,它精确显示了我想要的内容。 但是,当我尝试将应用程序运行到模拟器设备上时,查看结果是否看起来不错,但未显示属性文本。 仿真器设备仅显示纯文本。 如何使仿真器设备显示属性文本?

<!--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>

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

在此处输入图片说明

感谢您尝试解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM