首页 > 移动平台 > 详细

iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView

时间:2016-02-25 16:57:42      阅读:169      评论:0      收藏:0      [点我收藏+]

在须要模糊的UIView上。加入一个UIVisualEffectView对象就可以。

效果例如以下图:

技术分享



代码例如以下:


    UIImageView *imageview = [[UIImageViewalloc] init];

    imageview.frame =CGRectMake(10,100, 300, 300);

    imageview.image = [UIImageimageNamed:@"2"];

    imageview.contentMode =UIViewContentModeScaleAspectFit;

    imageview.userInteractionEnabled =YES;

    [self.viewaddSubview:imageview];

    

    UIBlurEffect *blur = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleLight];

    UIVisualEffectView *effectview = [[UIVisualEffectViewalloc] initWithEffect:blur];

    effectview.frame =CGRectMake(0,0, imageview.size.width/2,300);

    

    [imageviewaddSubview:effectview];

    

    

    UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeSystem];

    btn.frame =CGRectMake(10,50, 100, 40);

    [btn setTitle:@"btn"forState:UIControlStateNormal];

    [effectview.contentViewaddSubview:btn];



iOS开发交流群361513739

iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView

原文:http://www.cnblogs.com/gcczhongduan/p/5217586.html

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