在文本 Swift 末尾显示更多按钮

Show more button next to end of text Swift(在文本 Swift 末尾显示更多按钮)

本文介绍了在文本 Swift 末尾显示更多按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果空间不足,我想在文本末尾或下方显示更多按钮.我不明白苹果开发者是怎么做到的?请迅速回答.单击更多按钮后,我想显示所有文本.将按钮更改为更少.

I want to show more button at the end of the text or below if there isn't enough space. I don't understand how Apple developers did this? Please answer in swift. After clicking on more button i want to show all the text. change the button to less.

提前致谢.

推荐答案

这是一个很棒的 CocoaPod,可以满足您正在寻找的功能.

Here's a great CocoaPod for the functionality you're looking for.

https://github.com/ilyapuchka/ReadMoreTextView

这将允许您设置最大行数并自定义附加到修剪文本末尾的文本.您可以更改字体和颜色,因为它是 NSAttributedString.

This will allow you to set a maximum number of lines and customise the text append to the end of the trimmed text. You can change the font and color since it is an NSAttributedString.

这篇关于在文本 Swift 末尾显示更多按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在文本 Swift 末尾显示更多按钮

基础教程推荐