[英]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.