iOS - 毛玻璃動畫效果

来源:https://www.cnblogs.com/xujinzhong/archive/2018/04/11/8793436.html
-Advertisement-
Play Games

聲明全局變數 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

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前面的話 本文將詳細介紹一款用nodejs開發的基於Web的mongodb資料庫管理工具mongo-express 安裝 首先,全局安裝 mongo-express 包 接著,使用如下命令來找到mongo-express的安裝目錄 在win10下的輸出結果是: 然後進入該目錄下的node_modul ...
  • SQL query practice with MySQL [toc] 0.create table / Navicat Premium Data Transfer Source Server : localhost Source Server Type : MySQL Source Server ...
  • iPhone / iOS SDK 最酷的特性之一就是應用將其自身”綁定”到一個自定義 URL scheme 上,該 scheme 用於從瀏覽器或其他應用中啟動本應用。 註冊自定義 URL Scheme 註冊自定義 URL Scheme 的第一步是創建 URL Scheme — 在 Xcode Pro ...
  • 首先說:小米的垃圾支持.我在支持頁面上看著 miuiV4或V5版本,再看我手機上9.5的版本.就感覺有些不妙. 下載下來後,點擊安裝程式,提示我安裝空間不足......我F盤可用空間140G,不夠你造的? 最後解決辦法: 首先保證你的手機開了開發者模式 和 USB調試 還有USB安裝. 下載360手 ...
  • 首先,介紹一下UIView相關的動畫。 動畫屬性設置: 舉2個例子: 2. UIView Block動畫 這3個動畫比較簡單,不再多做敘述。 Spring動畫ios7.0以後新增了Spring動畫(IOS系統動畫大部分採用Spring Animation, 適用所有可被添加動畫效果的屬性) Keyf ...
  • 蘋果開發者賬號中,測試機器列表達到100臺上限,想要刪除一些設備、添加新設備,怎麼辦? 我們公司規模比較大,項目也比較多,最近就遇到了開發過程中發現新的iPhone添加不到測試設備中,在蘋果開發者中心添加新設備給予下麵的提示 意思是說測試設備已達到100台的上限,於是以為把原來添加的設備“Disab ...
  • ReactiveObjC使用 ReactiveCocoa是Github開源的一個用於iOS和OS開發的新框架,Cocoa是蘋果整套框架的簡稱。敢自稱為XXXCocoa框架可以想象到這個框架的牛逼! 現在分為ReactiveObjC和ReactiveSwift,兩個框架的功能使用相似,本文主要介紹Re ...
  • 如果兩個不同的應用註冊了同樣的URL Scheme,那麼後安裝的應用會響應符合這種協議格式的URL。 如果你的應用的iPhone和iPad版是各自獨立的(即不是Universal類型的),那麼你就不應該給兩個版本的應用定義同樣的URL協議。如果用戶在同一個設備上先後安裝了兩個版本的應用,之後又刪除了 ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...