我需要在启动屏幕上添加一个商标上标,所以我在xml中的TextView中添加了两个片段,如下所示:
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="center" id="258" translatesAutoresizingMaskIntoConstraints="NO" fixedFrame="YES" usesAttributedText="YES" selectable="NO" editable="NO">
<rect key="frame" x="20" y="460" width="374" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" colorSpace="calibratedWhite" white="0" alpha="0"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<attributedString key="attributedText">
<fragment content="TrademarkedName ">
<attributes>
<color key="NSColor" colorSpace="calibratedRGB" red="1" green="1" blue="1" alpha="1"/>
<font key="NSFont" name="HelveticaNeue" family="Helvetica Neue" size="20"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content="TM">
<attributes>
<color key="NSColor" colorSpace="calibratedRGB" red="1" green="1" blue="1" alpha="1"/>
<font key="NSFont" name="HelveticaNeue" family="Helvetica Neue" size="12"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
</textView>
然而,"TM“正在与文本的底部基线对齐。
如何在XML中标出这个"TM“文本片段,使其垂直与顶部对齐,或将其基线设置为垂直顶部?
发布于 2018-03-27 17:45:21
在XCode上测试,没有Xamarin。
您需要添加以下内容:<integer key="NSSuperScript" value="1"/>
。
<fragment content="TM">
<attributes>
<color key="NSColor" colorSpace="calibratedRGB" red="1" green="1" blue="1" alpha="1"/>
<font key="NSFont" name="HelveticaNeue" family="Helvetica Neue" size="12"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
<integer key="NSSuperScript" value="1"/>
</attributes>
</fragment>
我是怎么得到它的?
在界面生成器中修改attributedText
并不容易,它很难(在这一点上不是真正友好的用户)。
所以在这种情况下,我要做的就是打开TextEdit.app,做我想做的事情,然后把它复制/粘贴到attributedText
框中。
然后,我只需打开Interface Builder文件作为源代码,找到它并给出代码行。
我猜你可以试试1的值,我让你试试。
https://stackoverflow.com/questions/49499267
复制相似问题