iOS笔记之_UITetxView文本选择复制

UITetxView文本选择复制

PasteboardTextView.m

#import "PasteboardTextView.h"

@implementation PasteboardTextView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.font = [UIFont systemFontOfSize:15.f];
        self.editable = NO;
        self.textColor = [UIColor grayColor];
        self.text = @"这里是UITextView中需要选中复制的文字";
        self.textAlignment = NSTextAlignmentCenter;
        self.backgroundColor = [UIColor yellowColor];
    }
    return self;
}

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender

{
    //屏蔽了除复制以外的功能
    if (action == @selector(copy:)) {
        return YES;
    }else{
        
        return NO;
    }
    
}

@end
ViewController.m

#import "PasteboardTextView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    PasteboardTextView *textv = [[PasteboardTextView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width,50)];
    
    [self.view addSubview:textv];
}
@end
就酱...
Paste_Image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容