菜鸟教程小白 发表于 2022-12-13 02:29:50

iOS:带有 "Show more"按钮的 UILabel


                                            <p><p>我在 UILabel 中有一大堆文本</p>

<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum eget tortor porttitor, aliquam magna bibendum...<strong>show more</strong></p>
</blockquote>

<p>当我点击“显示更多”时,它应该会展开</p>

<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum eget tortor porttitor, aliquam magna bibendum, venenatis nunc. Aenean commodo nisl vel semper blandit. Vivamus rhoncus, lorem sed mollis tristique, dolor velit molestie ligula, eget semper leo augue eu urna. <strong>show less</strong></p>
</blockquote>

<p>我应该如何实现这个?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您还可以使用 UITapGestureRecognizer 并在 UILabel 的 NSAttributedString 中检测点击位置。 <a href="https://stackoverflow.com/a/29352519/168594" rel="noreferrer noopener nofollow">Check out my answer here.</a>你甚至不需要继承任何东西。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS:带有&#34;Show more&#34;按钮的 UILabel,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/26294851/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/26294851/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS:带有 &#34;Show more&#34;按钮的 UILabel