对于您的问题,我有一种方法,请尝试以下示例。
1.第一个情节提要设计:我有一个UIButton
2.添加了黑色视图作为子视图
UIView *blackView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
blackView.backgroundColor=[UIColor blackColor];
blackView.alpha=0.6f;
[self.view addSubview:blackView];
现在的结果将是:
3.再添加一个UIImageView,其框架等于按钮框架
UIImageView *imageView=[[UIImageView alloc]init];
imageView.frame=self.button.frame; //getting current UIButton bounds
imageView.image=[UIImage imageNamed:@"add_img.png"];
[self.view addSubview:imageView];
现在看起来与您想要的相同:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句