原始地址:IOS开发之文本复制
本文基于富文本:DTCoreText
#import <Foundation/Foundation.h>
#import <MobileCoreServices/UTCoreTypes.h>//添加此框架
@interface UIPasteboard (AttributedString)
- (void) setAttributedString:(NSAttributedString *)attributedString;
@end
#import "UIPasteboard+AttributedString.h"
@implementation UIPasteboard (AttributedString)
- (void) setAttributedString:(NSAttributedString *)attributedString
{
//\ufffc为对象占位符,目的是当富文本中有图像时,只复制文本信息!!!
NSString *htmlString = [[attributedString string] stringByReplacingOccurrencesOfString:@"\ufffc" withString:@""];

本文介绍了在iOS开发中如何实现文本复制功能,特别是基于富文本库DTCoreText。通过为需要复制的视图添加长按事件,并重写相关方法,实现了文本的便捷复制操作。
最低0.47元/天 解锁文章
931

被折叠的 条评论
为什么被折叠?



