标签:
上面是效果图,左边添加了毛玻璃选项,右边为没有毛玻璃时的样子.下边出代码
第一种设置图片//设置背景图片
UIImage *image = [UIImage imageNamed:@"beautiful.jpg"];
UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];//设置边框大小和屏幕一般大
backgroundImage.image = image; //给bacegroundView设置图片
[self.view addSubview:backgroundImage];
[backgroundImage release];
第二种设置图片(较简便,代码量也比较少,一般我用第二种比较多):
UIImageView *backgroundImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"beautiful.jpg"]];
[self.view addSubview:backgroundImage];
[backgroundImage release];
二.添加毛玻璃效果
UIBlurEffect *logineffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *logineffectView = [[UIVisualEffectView alloc]initWithEffect:logineffect];
logineffectView.frame = CGRectMake(0, 0, backgroundImage.frame.size.width, backgroundImage.frame.size.height);
[backgroundImage addSubview:logineffectView];
现在就可以实现毛玻璃效果了!!!
标签:
原文地址:http://www.cnblogs.com/guominghao/p/4827958.html