[英]Single Launchscreen.storyboard splash image not displaying proportionally in various iOS devices in Xamarin Forms
[英]SuperScript in LaunchScreen.storyboard (AttributedString in Xamarin.Forms for iOS)
我需要在启动屏幕上添加商标上标,因此我将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>
但是,“ TM”正与文本的底部基线对齐。
如何在XML中为该“ TM”文本片段加上上标,以使其垂直对齐到顶部,或者将基线设置为垂直顶部?
在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>
我怎么得到的?
在Interface Builder中修改attributedText
并不容易,这很困难(对那个用户不是很友好的用户)。
因此,在这种情况下,我要做的就是打开TextEdit.app,执行我想要的操作,然后将其复制/粘贴到attributedText
框中。
然后,我只是打开Interface Builder文件作为源代码,找到它并给您一行。
我猜您可以使用1的值,我让您尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.