[英]SuperScript in LaunchScreen.storyboard (AttributedString in Xamarin.Forms for iOS)
I need to add a trademark superscript to my launchscreen, so I've added 2 fragments to a TextView in xml as follows: 我需要在启动屏幕上添加商标上标,因此我将2个片段添加到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>
However, the "TM" is getting aligned to the bottom baseline of the text. 但是,“ TM”正与文本的底部基线对齐。
How do I, in XML, superscript this "TM" text fragment to vertically-align it to the top and\\or set it's baseline to vertical top? 如何在XML中为该“ TM”文本片段加上上标,以使其垂直对齐到顶部,或者将基线设置为垂直顶部?
Tested on XCode, no Xamarin. 在XCode上测试,没有Xamarin。
You need to add this: <integer key="NSSuperScript" value="1"/>
. 您需要添加以下内容:
<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>
How did I get it? 我怎么得到的?
Modifying attributedText
in Interface Builder is not easy, it's hard (not really friendly user on that one). 在Interface Builder中修改
attributedText
并不容易,这很困难(对那个用户不是很友好的用户)。
So what I do in these case it to open TextEdit.app, do what I want and copy/paste it into the attributedText
box. 因此,在这种情况下,我要做的就是打开TextEdit.app,执行我想要的操作,然后将其复制/粘贴到
attributedText
框中。
Then I just open the Interface Builder file as Source code, find it and gave you the line. 然后,我只是打开Interface Builder文件作为源代码,找到它并给您一行。
I guess you can play with the value of 1, I'll let you try it. 我猜您可以使用1的值,我让您尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.