菜鸟教程小白 发表于 2022-12-12 21:41:49

ios - 如何调整 UITextField 占位符文本以适合 UITextField 宽度?


                                            <p><p>可以改变 UITextField 占位符文本颜色如下:</p>

<pre><code>
                  forKeyPath:@&#34;_placeholderLabel.textColor&#34;];
</code></pre>

<p>同样有没有办法调整 UITextField 占位符文本字体以适应 UITextField 宽度?</p>

<p>注意:我在表格 View 的自定义单元格中有文本字段,并且在自定义单元格中也使用了自动布局。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我遇到了同样的问题,解决方法如下:</p>

<pre><code>UILabel *placeHolderLabel = ;
placeHolderLabel.adjustsFontSizeToFitWidth = YES;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何调整 UITextField 占位符文本以适合 UITextField 宽度?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38822888/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38822888/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何调整 UITextField 占位符文本以适合 UITextField 宽度?