首页 > 移动平台 > 详细

iOS 毛玻璃效果

时间:2015-09-22 10:06:47      阅读:233      评论:0      收藏:0      [点我收藏+]

技术分享技术分享

上面是效果图,左边添加了毛玻璃选项,右边为没有毛玻璃时的样子.下边出代码

第一种设置图片//设置背景图片

    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];

现在就可以实现毛玻璃效果了!!!

iOS 毛玻璃效果

原文:http://www.cnblogs.com/guominghao/p/4827958.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!