菜鸟教程小白 发表于 2022-12-11 19:47:51

ios - 在 UITableViewCell 中动态调整 UILabel?


                                            <p><p>我想动态调整 UILabel 中的行数。例如,可能存在长字符串或短字符串。如果少于 10 个字符,则应为 1 行。如果有 10-20 个字符,应该是两行。此 UILabel 位于 UITableViewCell 内。目前,如果有一个长字符串,那么 UILabel 只会在空间不足的地方显示“...”,因此字符串被切断。我怎样才能防止这种情况发生?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>试试:</p>

<p><code>nameOfLabel.numberOfLines = 0</code></p>

<p>0 应该是动态的。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 UITableViewCell 中动态调整 UILabel?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/48981992/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/48981992/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 UITableViewCell 中动态调整 UILabel?