- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(click)];
[self.view addGestureRecognizer:tap];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 350, 400);
button.backgroundColor = [UIColor redColor];
[self.view addSubview:button];
[button addTarget:self action:@selector(kkk) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"我是一个按钮" forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:80];
button.titleLabel.numberOfLines = 0;
UILabel *ve = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
ve.backgroundColor = [UIColor cyanColor];
ve.text = @"我是label1";
ve.userInteractionEnabled = YES;
[self.view addSubview:ve];
UILabel *ve2 = [[UILabel alloc] initWithFrame:CGRectMake(100, 500, 100, 100)];
ve2.backgroundColor = [UIColor magentaColor];
ve2.text = @"我是label2";
ve2.userInteractionEnabled = YES;
[self.view addSubview:ve2];
// Do any additional setup aft
// Do any additional setup after loading the view.
}
- (void)kkk
{
NSLog(@"按钮按钮");
}
- (void)click
{
NSLog(@"手势点击手势点击");
}
![请添加图片描述](http://www.kaotop.com/file/tupian/20220518/f828973c6fec4629a1cf224d211fef60.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YiY5YiY5bCP5Y2a,size_20,color_FFFFFF,t_70,g_se,x_16)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)