FXBlurView用法

FXBlurView是UIView的子类,它实现毛玻璃效果的原理其实就是覆盖上一层FXBlurView的实例对象。

 

 1 - (void)viewDidLoad {
 2     [super viewDidLoad];
 3 
 4     UIImageView * imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
 5     imageView.image = [UIImage imageNamed:@"Default-Port-hd47"];
 6     [self.view addSubview:imageView];
 7 
 8     FXBlurView * aview = [[FXBlurView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
 9     aview.tintColor = [UIColor whiteColor];  //前景颜色
10     aview.blurRadius = 20.0;                 //模糊半径
11     aview.dynamic = YES;                     //动态改变模糊效果    
12     [self.view addSubview:aview];
13 
14     FXBlurView * bview = [[FXBlurView alloc] initWithFrame:CGRectMake(0, 120, 100, 100)];
15     bview.tintColor = [UIColor whiteColor];  //前景颜色
16     bview.blurEnabled = YES;                //是否允许模糊,默认YES
17     bview.blurRadius = 10.0;               //模糊半径
18     bview.dynamic = YES;                   //动态改变模糊效果
19     bview.iterations = 2;                  //迭代次数:
20     bview.updateInterval = 2.0;            //更新时间(不确定具体功能)
21 
22     /*
23      blurRadius = 1.0 && dynamic = 100 的效果和 blurRadius = 10.0 && dynamic = 1的效果大致相同
24      */    
25 
26     [self.view addSubview:bview];
27 
28     FXBlurView * cview = [[FXBlurView alloc] initWithFrame:CGRectMake(150, 0, 200, 200)];
29     cview.blurRadius = 20.0;
30     cview.tintColor = [UIColor whiteColor];
31     [self.view addSubview:cview];
32 }

 

 

 

demo下载:https://github.com/nicklockwood/FXBlurView

posted on 2015-05-25 21:02  陌上红尘  阅读(1973)  评论(0编辑  收藏  举报

导航