博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS - 毛玻璃动画效果
阅读量:6940 次
发布时间:2019-06-27

本文共 5933 字,大约阅读时间需要 19 分钟。

声明全局变量

#define kMainBoundsHeight   ([UIScreen mainScreen].bounds).size.height //屏幕的高度#define kMainBoundsWidth    ([UIScreen mainScreen].bounds).size.width //屏幕的宽度const CGFloat animalDuration  = 0.25;   //添加动画延时效果

ViewController.m

////  ViewController.m//  iPhone////  Created by zlw on 2018/4/10.//  Copyright © 2018年 xujinzhong. All rights reserved.//#import "ViewController.h"#import "Masonry.h"#import "ReactiveObjC.h"#import "showV.h"@interface ViewController ()@end@implementation ViewController{    UIButton *_doneBtn;}- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    self.view.backgroundColor = [UIColor whiteColor];        _doneBtn = [[UIButton alloc] init];    _doneBtn.backgroundColor = [UIColor grayColor];    _doneBtn.layer.cornerRadius = 4;    _doneBtn.layer.masksToBounds = YES;    [_doneBtn setTitle:@"show" forState:UIControlStateNormal];    [self.view addSubview:_doneBtn];        [_doneBtn mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.offset(100);        make.centerX.equalTo(self.view);        make.width.offset(80);        make.height.offset(100);    }];        __block showV *_showView;    [[_doneBtn rac_signalForControlEvents:UIControlEventTouchDown]subscribeNext:^(__kindof UIControl * _Nullable x) {        _showView = [[showV alloc] init];        [self.view addSubview:_showView];        _showView.frame = CGRectMake(0, 0, kMainBoundsWidth, kMainBoundsHeight);        [_showView showViewData];    }];}@end

 

showV.h

////  showV.h//  iPhone////  Created by zlw on 2018/4/10.//  Copyright © 2018年 xujinzhong. All rights reserved.//#import 
@interface showV : UIView-(void)showViewData;@end

showV.m

////  showV.m//  iPhone////  Created by zlw on 2018/4/10.//  Copyright © 2018年 xujinzhong. All rights reserved.//#import "showV.h"#import "Masonry.h"#import "ReactiveObjC.h"@interface showV ()@property(nonatomic, strong) UIView *bkView;@property(nonatomic, strong) UIVisualEffectView *alphView;@property(nonatomic, strong) NSString *content;@end@implementation showV-(instancetype)init{    self = [super init];        if (self) {        self.backgroundColor = [UIColor whiteColor];    }        return self;}-(NSString *)content{    if (!_content) {        _content = @"您将要激活闪电下单模式。通过点击下面的“我接受这些合同条款”,您会承认您已经阅读并理解以下合同条款,您同意特此遵守。您当前的程序端版本使您在下面的订单提交模式间选择。您同意遵守本规定的条款和条件,有关这样的模式。\n\n1. 订单提交的默认模式是两步处理法。使用默认模式,您需先选择买卖方向,然后您需要选择一个合适的订单类型,它的参数并且根据您选定的具体订单类型和您的交易意愿,通过点击买入,卖出,下单,确认您订单的提交。使用默认模式,您的订单将直到您完成前面提到的两个步骤才会提交。\n\n2. 订单提交的闪电下单模式是一步处理法。使用闪电下单模式,您的订单将会被直接提交,而无需再次确认。不会有后续确认提示您点击。一旦您点击,您将无法撤销或更改您的订单。在正常市场条件和系统性能下,市价订单提交后,单子会立即成交。\n\n您可以在【开启闪电下单按钮】停用闪电下单模式。\n\n通过选择闪电下单模式,您了解到您的订单将根据您点击卖或买价进行提交,没有后续订单确认。您同意并接受您选择的订单提交模式相关的全部风险,包括,但不限于,过失风险,提交订单时发生的失误。\n\n您同意完全赔偿和使ZLW TRADING 在由您,您的交易经理或任何代表您进行交易的人,造成的任何错误遗漏或失误而导致的结果引起的各种损失,成本和费用上免受损失。\n";    }    return _content;}-(void)showViewData{    UIColor *bkColor = [UIColor blackColor];    UIColor *whileColor = [UIColor whiteColor];    UIColor *grayColor = [UIColor grayColor];        UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];    _alphView = [[UIVisualEffectView alloc] initWithEffect:beffect];    [self addSubview:_alphView];    _alphView.alpha = 0;        [_alphView mas_makeConstraints:^(MASConstraintMaker *make) {        make.edges.equalTo(self);    }];        self.bkView = [[UIView alloc] init];    [self addSubview:self.bkView];    self.bkView.backgroundColor = bkColor;    self.bkView.frame = CGRectMake(0, kMainBoundsHeight-100, kMainBoundsWidth, 500);        UILabel *labTitle = [UILabel new];    labTitle.text = @"免责声明";    labTitle.textAlignment = NSTextAlignmentCenter;    labTitle.backgroundColor = bkColor;    labTitle.textColor = whileColor;    [self.bkView addSubview:labTitle];        [labTitle mas_makeConstraints:^(MASConstraintMaker *make) {        make.left.top.equalTo(self.bkView);        make.width.equalTo(self.bkView);        make.height.offset(50);    }];        UITextView *textV = [UITextView new];    textV.backgroundColor = bkColor;    textV.textColor = grayColor;    textV.font = [UIFont systemFontOfSize:14];    textV.text = self.content;    textV.editable = NO;    [self.bkView addSubview:textV];        [textV mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(labTitle.mas_bottom);        make.centerX.equalTo(self.bkView);        make.width.equalTo(self.bkView).offset(-20);        make.bottom.equalTo(self.bkView).offset(-50);    }];        UIButton *closeBtn = [UIButton new];    [closeBtn setTitle:@"关闭" forState:UIControlStateNormal];    closeBtn.backgroundColor = [UIColor blueColor];    [self.bkView addSubview:closeBtn];    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(textV.mas_bottom);        make.centerX.equalTo(textV);        make.width.equalTo(self.bkView);        make.bottom.equalTo(self.bkView);    }];        [[closeBtn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(__kindof UIControl * _Nullable x) {        [UIView animateWithDuration:animalDuration animations:^{            self.alphView.alpha = 0.0;            self.bkView.frame = CGRectMake(0, kMainBoundsHeight, kMainBoundsWidth, 500);        } completion:^(BOOL finished) {            [self removeFromSuperview];        }];    }];        [UIView animateWithDuration:animalDuration animations:^{        self.alphView.alpha = 1.0;        self.bkView.frame = CGRectMake(0, kMainBoundsHeight-505, kMainBoundsWidth, 500);    }];}- (void)touchesBegan:(NSSet
*)touches withEvent:(UIEvent *)event{ [UIView animateWithDuration:animalDuration animations:^{ self.alphView.alpha = 0.0; self.bkView.frame = CGRectMake(0, kMainBoundsHeight, kMainBoundsWidth, 500); } completion:^(BOOL finished) { [self removeFromSuperview]; }]; }@end

 

转载于:https://www.cnblogs.com/xujinzhong/p/8793436.html

你可能感兴趣的文章
DNS基本工作原理,及正反向解析和主从同步测试
查看>>
安装Nginx
查看>>
在树莓派2/B+上安装Python和OpenCV
查看>>
有意思的python***案例
查看>>
PHP Warning 报“timezone”错
查看>>
思科CCIE证书真伪、有效性查询方式
查看>>
局域网内搭建 本地yum 源
查看>>
golang: 常用数据类型底层结构分析
查看>>
How to Set Cores-Per-Socket Parameter for a Virtual Machine
查看>>
我的友情链接
查看>>
如何做出一个弹出窗口
查看>>
solidity 0.5.7简明教程
查看>>
你好啊中国
查看>>
冯柯:同步设计在高性能OLTP数据库中的实践
查看>>
iPhone史上最全的使用教程
查看>>
推广一款不错的应用“锁屏对对碰”
查看>>
Oracle IO问题解析(九)
查看>>
How to Properly Remove Datastore or LUN from ESXi 5.x hosts
查看>>
[读书]读《重构-改善既有代码的设计》
查看>>
我的友情链接
查看>>