欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門教程網(wǎng)!

IOS

當(dāng)前位置:主頁(yè) > 軟件編程 > IOS >

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

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-11|欄目:IOS|點(diǎn)擊: 次

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

效果圖

預(yù)覽圖

思路

在當(dāng)前ViewController下Present另外一個(gè)AnimationViewController,在彈出的AnimationViewController中 動(dòng)畫(huà),彈出的時(shí)候原來(lái)的ViewController上有一個(gè)全屏覆蓋的maskView,在彈出時(shí),有一個(gè)漸變動(dòng)畫(huà)(頁(yè)面漸黑),在AnimationViewController聲明一個(gè)代理,在代理方法中實(shí)現(xiàn)收起的動(dòng)畫(huà)效果(dissmissController和maskView消失)

主要代碼

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ì)覆蓋在原來(lái)的控制器之上

- (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)

- (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)畫(huà)這里用到的是Lottie這個(gè)動(dòng)畫(huà)開(kāi)源庫(kù)(Airbnb),這個(gè)開(kāi)源庫(kù)主要的功能是可以將After Effects制作的動(dòng)畫(huà)通過(guò)插件導(dǎo)出為json格式的文件,然后通過(guò)這個(gè)開(kāi)源庫(kù)解析成動(dòng)畫(huà)。

- (void)onConfirmButtonClick
{
  if ([self.delegate respondsToSelector:@selector(onAirPodsAnimationViewControllerConfirmButtonClick:)]) {
    [self dismissViewControllerAnimated:YES completion:nil];
    [self.delegate onAirPodsAnimationViewControllerConfirmButtonClick:self];
  }
}

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

- (void)onAirPodsAnimationViewControllerConfirmButtonClick:(HCAirPodsAnimationViewController *)vc
{
  [UIView animateWithDuration:0.2 animations:^{
    self.maskBgView.alpha = 0.0;
  } completion:nil];
}

項(xiàng)目地址:AirPodsAnimation

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:iOS常見(jiàn)算法以及應(yīng)用知識(shí)點(diǎn)總結(jié)

欄    目:IOS

下一篇:iOS多Target環(huán)境配置的完整步驟

本文標(biāo)題:iOS仿AirPods彈出動(dòng)畫(huà)

本文地址:http://mengdiqiu.com.cn/a1/IOS/11859.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有