效果圖 2017-06-30 下午6.22.36.png
使用兩個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];