一,效果图。

【代码笔记】iOS-可拷贝的label

二,工程图。

【代码笔记】iOS-可拷贝的label

三,代码。

ViewController.m

【代码笔记】iOS-可拷贝的label
#import "ViewController.h"
#import "MKBeCopyLabel.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    MKBeCopyLabel *copyLabel = [[MKBeCopyLabel alloc]initWithFrame:CGRectMake(10, 100, 100, 60)];
    copyLabel.backgroundColor=[UIColor redColor];
    copyLabel.text=@"111111";
    copyLabel.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapCopyText = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapToCopyText:)];
    [copyLabel addGestureRecognizer:tapCopyText];
    [self.view addSubview:copyLabel];

}
- (void)handleTapToCopyText:(UITapGestureRecognizer *)sender
{
    MKBeCopyLabel * targetLabel = (MKBeCopyLabel *)sender.view;
    [targetLabel handleLongTap];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
【代码笔记】iOS-可拷贝的label

相关文章:

  • 2021-06-23
  • 2021-05-12
  • 2021-05-08
  • 2021-10-13
  • 2021-11-24
  • 2021-11-17
  • 2021-09-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2022-01-06
  • 2022-12-23
  • 2021-07-09
  • 2021-10-10
相关资源
相似解决方案