菜鸟教程小白 发表于 2022-12-11 20:05:25

ios - 文本输入垂直对齐


                                            <p><p>有人知道如何使用自定义字体(内容和占位符)修复 TextInput 的垂直对齐吗?我尝试了所有这些:</p>

<ul>
<li>justifyContent:“中心”,</li>
<li>alignItems:'居中',</li>
<li>textAlign: '居中',</li>
<li>textAlignVertical: ‘居中’,</li>
</ul>

<p>没有任何作用!有什么建议吗?</p>

<p> <a href="/image/KT5X9.png" rel="noreferrer noopener nofollow"><img src="/image/KT5X9.png" alt="enter image description here"/></a> </p>

<pre><code>         &lt;TextInput
            ref={ref =&gt; this.emailField = ref}
            placeholder=&#34;E-Mail&#34;
            style={styles.loginInput}
            placeholderStyle={styles.loginInput}
            editable={true}
            maxLength={40}
            autoCorrect={false}
            selectionColor=&#34;#9D9D9D&#34;
            placeholderTextColor=&#34;#9D9D9D&#34;
            autoCapitalize=&#34;none&#34;
            keyboardType=&#34;email-address&#34;
            returnKeyType=&#34;next&#34;
            keyboardAppearance=&#34;dark&#34;
            textAlign=&#34;center&#34;
            underlineColorAndroid=&#34;transparent&#34;
            onSubmitEditing={() =&gt; this.passwordField.focus()}
            value={this.state.email}
            onChangeText={(text) =&gt; this.setState({ email: text })}
          /&gt;

loginInput: {
    width: &#39;70%&#39;,
    height: 40,
    marginBottom: 8,
    backgroundColor: &#39;#dbdbdb&#39;,
    fontFamily: &#39;Neuzeit Grotesk Regular&#39;,
    fontSize: 18,
    justifyContent: &#39;center&#39;,
    alignItems: &#39;center&#39;,
    textAlign: &#39;center&#39;,
    textAlignVertical: &#39;center&#39;,
},
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我遇到了同样的问题。 TextInput 有一个默认的填充,
就我而言。我在 <code>TextInput</code> 样式中添加了 <code>paddingTop: 0</code>, <code>paddingBottom: 0</code>。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 文本输入垂直对齐,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/50064386/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/50064386/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 文本输入垂直对齐