UIToolBar实现毛玻璃效果

在viewDidLoad方法里实现以下代码就可以实现毛玻璃效果:

    UIImageView *imageView1 = [[UIImageView alloc] init];
    imageView1.frame = self.view.bounds;
    imageView1.backgroundColor = [UIColor redColor];
    
    //01为图片的名字
    imageView1.image = [UIImage imageNamed:@"01"];
    
    imageView1.contentMode = UIViewContentModeScaleAspectFill;
    
    //创建一个毛玻璃
    UIToolbar *toolBar = [[UIToolbar alloc] init];
    toolBar.frame = imageView1.bounds;
    
    //设置毛玻璃的样式
    toolBar.barStyle = UIBarStyleBlack;
    toolBar.alpha = 0.98;
    [imageView1 addSubview:toolBar];
    
    [self.view addSubview:imageView1];``` 

你可能感兴趣的:(UIToolBar实现毛玻璃效果)