简单的半透明遮罩层的生成,具体的alpha、样式可以根据自己的需求进行调节,代码如下:
#import "ViewController.h"
#define screenW self.view.bounds.size.width
#define screenH self.view.bounds.size.height
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
/**
* xib - button click - 生成半透明遮罩层
*/
- (IBAction)translucentMaskButtonClick:(UIButton *)sender {
UIToolbar *toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, screenW, screenH)];
//样式
toolbar.barStyle = UIBarStyleBlackTranslucent;//半透明
//透明度
toolbar.alpha = 0.5f;
[self.view addSubview:toolbar];
}
@end