聲明全局變數 ViewController.m showV.h showV.m ...
聲明全局變數
#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 <UIKit/UIKit.h> @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<UITouch *> *)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