激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - IOS - iOS仿AirPods彈出動(dòng)畫

iOS仿AirPods彈出動(dòng)畫

2021-05-28 16:02Peter_Huang0623 IOS

這篇文章主要為大家詳細(xì)介紹了iOS仿AirPods彈出動(dòng)畫的實(shí)現(xiàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了ios仿airpods彈出動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下

效果圖

iOS仿AirPods彈出動(dòng)畫

預(yù)覽圖

思路

在當(dāng)前viewcontroller下present另外一個(gè)animationviewcontroller,在彈出的animationviewcontroller中播放動(dòng)畫,彈出的時(shí)候原來的viewcontroller上有一個(gè)全屏覆蓋的maskview,在彈出時(shí),有一個(gè)漸變動(dòng)畫(頁面漸黑),在animationviewcontroller聲明一個(gè)代理,在代理方法中實(shí)現(xiàn)收起的動(dòng)畫效果(dissmisscontroller和maskview消失)

主要代碼

?
1
2
3
4
5
6
7
8
9
10
11
hcairpodsanimationviewcontroller *vc = [[hcairpodsanimationviewcontroller alloc] init];
  vc.delegate = self;
  vc.modalpresentationstyle = uimodalpresentationovercurrentcontext;
  
  [uiview animatewithduration:0.2 animations:^{
    self.maskbgview.alpha = 0.5;
  } completion:nil];
  
  [self presentviewcontroller:vc animated:yes completion:^{
    [vc.animationview play];
  }];

模態(tài)跳轉(zhuǎn)的style有一個(gè)枚舉值,在ios13以前modalpresentationstyle的默認(rèn)值為uimodalpresentationfullscreen,ios13以后變成了uimodalpresentationpagesheet,在這里我們把style設(shè)置為uimodalpresentationovercurrentcontext彈出的這個(gè)控制器就會(huì)覆蓋在原來的控制器之上

?
1
2
3
4
5
6
7
8
9
10
- (uiview *)maskbgview
{
  if (!_maskbgview) {
    _maskbgview = [[uiview alloc] initwithframe:cgrectmake(0, 0, [uiscreen mainscreen].bounds.size.width, [uiscreen mainscreen].bounds.size.height)];
    _maskbgview.backgroundcolor = [uicolor blackcolor];
    _maskbgview.alpha = 0;
    [self.view addsubview:_maskbgview];
  }
  return _maskbgview;
}

一個(gè)覆蓋全屏的maskview采用懶加載的方式實(shí)現(xiàn)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
- (void)initcontentview
{
  cgfloat containerw = screen_width - 20;
  cgfloat containerh = containerw * 0.9;
  uiview *containerview = [[uiview alloc] initwithframe:cgrectmake(10, screen_height - containerh - 10, containerw, containerh)];
  containerview.layer.cornerradius = 20;
  containerview.backgroundcolor = [uicolor whitecolor];
  [self.view addsubview:containerview];
  
  self.animationview = [[lotanimationview alloc] initwithframe:cgrectmake(70, 70, containerw - 140, containerh - 140)];
  [containerview addsubview:self.animationview];
  self.animationview.animation = @"gift_animation";
  
  self.animationview.loopanimation = yes;
  
  uibutton *confirmbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 200, 34)];
  confirmbutton.center = cgpointmake(self.animationview.center.x, containerh - 44);
  
  [confirmbutton settitle:@"close" forstate:uicontrolstatenormal];
  [confirmbutton settitlecolor:[uicolor whitecolor] forstate:uicontrolstatenormal];
  
  [confirmbutton setbackgroundcolor:[uicolor bluecolor]];
  confirmbutton.layer.cornerradius = 10;
  
  [confirmbutton addtarget:self action:@selector(onconfirmbuttonclick) forcontrolevents:uicontroleventtouchupinside];
  [containerview addsubview:confirmbutton];
}

動(dòng)畫這里用到的是lottie這個(gè)動(dòng)畫開源庫(airbnb),這個(gè)開源庫主要的功能是可以將after effects制作的動(dòng)畫通過插件導(dǎo)出為json格式的文件,然后通過這個(gè)開源庫解析成動(dòng)畫。

?
1
2
3
4
5
6
7
- (void)onconfirmbuttonclick
{
  if ([self.delegate respondstoselector:@selector(onairpodsanimationviewcontrollerconfirmbuttonclick:)]) {
    [self dismissviewcontrolleranimated:yes completion:nil];
    [self.delegate onairpodsanimationviewcontrollerconfirmbuttonclick:self];
  }
}

dissmiss當(dāng)前的控制器,讓viewcontroller來實(shí)現(xiàn)這個(gè)代理方法,并且在代理方法中隱藏maskview

?
1
2
3
4
5
6
- (void)onairpodsanimationviewcontrollerconfirmbuttonclick:(hcairpodsanimationviewcontroller *)vc
{
  [uiview animatewithduration:0.2 animations:^{
    self.maskbgview.alpha = 0.0;
  } completion:nil];
}

項(xiàng)目地址:airpodsanimation

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/Peter_Huang0623/article/details/103533619

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: h视频免费看 | 国产影视 | 久久逼网| 免费视频aaa | 亚洲精品aⅴ中文字幕乱码 欧美囗交 | 粉嫩粉嫩一区二区三区在线播放 | 久久精品人人做人人爽 | 国产一区二区三区手机在线 | 大学生a级毛片免费视频 | 黄色影院在线看 | av成人在线观看 | 午夜精品视频免费观看 | 国产精品亚洲欧美一级在线 | 激情九九 | 国产免费看片 | 欧美国产日韩在线 | www.成人免费视频 | 1314av| 成人做爰高潮片免费视频韩国 | 精品视频 久久久 | 国产亚洲精品久久久久久大师 | 欧美一级黄色录像片 | 一及毛片视频 | 四虎久草 | 国产精品国产成人国产三级 | 毛片在线免费观看完整版 | 久久精品视频3 | 国产精品久久久久久久久久妇女 | 国产chinesehd精品91 | 噜噜在线视频 | 欧美国产一区二区三区 | 精品久久久久久亚洲精品 | 精品av在线播放 | xxx日本视频 | xvideos korean | www.99av| 88xx成人永久免费观看 | 久草在线资源福利站 | 全黄毛片 | 韩国一大片a毛片 | fc2成人免费人成在线观看播放 |