首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >LaunchScreen.storyboard中的SuperScript (iOS的Xamarin.Forms中的AttributedString)

LaunchScreen.storyboard中的SuperScript (iOS的Xamarin.Forms中的AttributedString)
EN

Stack Overflow用户
提问于 2018-03-27 03:34:10
回答 1查看 184关注 0票数 1

我需要在启动屏幕上添加一个商标上标,所以我在xml中的TextView中添加了两个片段,如下所示:

代码语言:javascript
运行
复制
<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“文本片段,使其垂直与顶部对齐,或将其基线设置为垂直顶部?

EN

回答 1

Stack Overflow用户

发布于 2018-03-27 17:45:21

在XCode上测试,没有Xamarin。

您需要添加以下内容:<integer key="NSSuperScript" value="1"/>

代码语言:javascript
运行
复制
<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的值,我让你试试。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49499267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档