最近公司的项目中要求消息界面的内容可以供用户复制。但是之前完全没想到会这么做,直接用label写的界面。目前用过的控件中有三个控件是可以复制的:
1.UITextView
2.UITextField
3.UIWebView

首先是常规的初始化方式:

初始化中添加长按手势:

重写基类中方法:


以上即可实现带复制功能的label,但是如果想随意复制某一段文字,还需要进一步研究。
最近公司的项目中要求消息界面的内容可以供用户复制。但是之前完全没想到会这么做,直接用label写的界面。目前用过的控件中有三个控件是可以复制的:
1.UITextView
2.UITextField
3.UIWebView
以上即可实现带复制功能的label,但是如果想随意复制某一段文字,还需要进一步研究。
本文标题:可以复制文字的Label
本文链接:https://www.haomeiwen.com/subject/rsqfwftx.html
网友评论