请选择 进入手机版 | 继续访问电脑版
尚学堂集团旗下品牌:尚学堂速学堂百战程序员云数学院[切换校区]

IOS开发——毛玻璃 隐藏

| 开发 0 289
简单的毛玻璃效果:
  • 原图

    原图


  • 毛玻璃效果

    毛玻璃效果

  • 代码如下:

#import "ViewController.h"#import <CoreImage/CoreImage.h>@interface ViewController ()@property (nonatomic, strong) UIImageView *imageView;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    self.imageView = [[UIImageView alloc]initWithFrame:self.view.frame];    self.imageView.image = [UIImage imageNamed:@"1.jpg"];    self.imageView.contentMode = UIViewContentModeScaleAspectFill;    [self.view addSubview:self.imageView];    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];    button.frame = CGRectMake(0, self.view.frame.size.height - 80, self.view.frame.size.width, 40);    [button setTitle:@"蒙奇·D·路飞" forState:UIControlStateNormal];    button.backgroundColor = [UIColor brownColor];    [button addTarget:self action:@selector("点击调用的方法") forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:button];}
button 被点击时调用以下代码:
    self.imageView = [[UIImageView alloc] initWithFrame:self.view.frame];    self.imageView.image = [UIImage imageNamed:@"1.jpg"];    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blur];    visualEffectView.frame = self.view.frame;    [self.imageView addSubview:visualEffectView];    UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blur];    UIVisualEffectView *ano = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];    ano.frame = self.view.frame;    UILabel *label = [[UILabel alloc] init];    label.font = [UIFont systemFontOfSize:40];    label.frame = CGRectMake(0, self.view.frame.size.height - 120, self.view.frame.size.width, 80);    label.textAlignment = NSTextAlignmentCenter;    label.text = @"蒙奇·D·路飞";    [visualEffectView.contentView addSubview:ano];    [ano.contentView addSubview:label];    [self.view addSubview:self.imageView];
分享到 :
人收藏 回复 使用道具
*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

返回顶部