iOS中添加毛玻璃状态的视图效果

来源:互联网 发布:mysql 密码修改 编辑:程序博客网 时间:2024/06/01 15:17

原文链接:http://blog.sina.com.cn/s/blog_a5243c7f0102vjxc.html


UIImageView * imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"girl.png"]];

    imageview.userInteractionEnabled = YES;

    imageview.contentMode = UIViewContentModeScaleAspectFit;

    imageview.frame = CGRectMake(0, 80, 320, 320);

    [self.view addSubview:imageview];

    

    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

    

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

    

    effectview.frame = CGRectMake(0, 0, imageview.frame.size.width, 320);

    

    [imageview addSubview:effectview];

    

    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

    

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

    

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

    

    [effectview.contentView addSubview:button];

0 0
原创粉丝点击