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

 - (void)viewDidLoad {
[super viewDidLoad]; UIImageView * imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
imageView.image = [UIImage imageNamed:@"Default-Port-hd47"];
[self.view addSubview:imageView]; FXBlurView * aview = [[FXBlurView alloc] initWithFrame:CGRectMake(, , , )];
aview.tintColor = [UIColor whiteColor]; //前景颜色
aview.blurRadius = 20.0; //模糊半径
aview.dynamic = YES; //动态改变模糊效果
[self.view addSubview:aview]; FXBlurView * bview = [[FXBlurView alloc] initWithFrame:CGRectMake(, , , )];
bview.tintColor = [UIColor whiteColor]; //前景颜色
bview.blurEnabled = YES; //是否允许模糊,默认YES
bview.blurRadius = 10.0; //模糊半径
bview.dynamic = YES; //动态改变模糊效果
bview.iterations = ; //迭代次数:
bview.updateInterval = 2.0; //更新时间(不确定具体功能) /*
blurRadius = 1.0 && dynamic = 100 的效果和 blurRadius = 10.0 && dynamic = 1的效果大致相同
*/ [self.view addSubview:bview]; FXBlurView * cview = [[FXBlurView alloc] initWithFrame:CGRectMake(, , , )];
cview.blurRadius = 20.0;
cview.tintColor = [UIColor whiteColor];
[self.view addSubview:cview];
}

FXBlurView用法-LMLPHP

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

04-30 01:50