我有一个带有标签的按钮。标签挡住了按钮,所以我无法单击它。
timerView = [[UIView alloc] initWithFrame:CGRectMake(0, 278, 105, 27)];
[self.view addSubview:timerView];
UIButton *timerBackground = [UIButton buttonWithType:UIButtonTypeCustom];
[timerBackground setBackgroundImage:[UIImage imageNamed:@"Time Background.png"] forState:UIControlStateNormal];
[timerBackground setBackgroundImage:[UIImage imageNamed:@"Time Background.png"] forState:UIControlStateHighlighted];
[timerBackground addTarget:self action:@selector(openTimeChanger) forControlEvents:UIControlEventTouchUpInside];
timerBackground.frame = CGRectMake(-2 , 15, 102, 27);
[timerView addSubview:timerBackground];
DateDay = [[UILabel alloc] initWithFrame:CGRectMake(6, 4, 20, 21)];
DateDay.backgroundColor = [UIColor clearColor];
DateDay.textColor = [UIColor whiteColor];
[timerBackground addSubview:DateDay];
我希望标签对点击是“透明的”,所以我可以点击按钮。