使用两个view
{
UILabel *aLabel;
UIView *bView;
UIView *cView;
UIButton *btn;
}
bView =[[UIView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.width)];
[self.view addSubview:bView];
bView.userInteractionEnabled = YES;
bView.backgroundColor=[UIColor colorWithWhite:0.1 alpha:0.9];
cView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 260, 260)];
cView.userInteractionEnabled = YES;
[bView addSubview:cView];
cView.backgroundColor=[UIColor blueColor];
aLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 260, 260)];
aLabel.userInteractionEnabled = YES;
aLabel.numberOfLines = 0;
aLabel.text = @"有文字的这里";//这里是文字。假如是数字的话就不需要cView也行。
aLabel.font = [UIFont systemFontOfSize:12];
[bView addSubview:aLabel];
aLabel.backgroundColor=[UIColor clearColor];//设置成透明,相当于一个覆盖
btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(0, 0, 80, 40);
[btn setBackgroundColor:[UIColor redColor]];
[btn setTitle:[NSString stringWithFormat:@"不显示吗"] forState:UIControlStateNormal];
[aLabel addSubview:btn];
网友评论