iOS8使用UIVisualEffectView实现模糊效果

2021-10-29 11:53:09 浏览数 (1)

代码语言:javascript复制
- (void)viewDidLoad {  
        [super viewDidLoad];  
        // Do any additional setup after loading the view, typically from a nib.  
        //使用图片初始化背景色  
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gradient2"]];  
        //实现模糊效果  
        UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];  
        visualEffectView.frame = self.view.bounds;  
        visualEffectView.alpha = 1.0;  
        [self.view addSubview:visualEffectView];  
    }  

0 人点赞