使用Swift怎么实现一个最小化语音通话功能

  介绍

本篇文章为大家展示了使用Swift怎么实现一个最小化语音通话功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

SuspendTool

import 基础   import  UIKit      enum  SuspendType  {   case 没有一个   case 单   case 多   }      class  SuspendTool:, NSObject  {      ,static  let  sharedInstance =, SuspendTool ()   ,private  var  suspendWindows: [SuspendWindow],=, []//,var 半圆,半圆?   ,var 产地:CGPoint =, CGPoint.init (10 x:,,, y,, 300)      ,static  func  showSuspendWindow (rootViewController:,, ui, coverImageName:,字符串),{   ,let  tool =SuspendTool.sharedInstance   ,let  window =, SuspendWindow.init (rootViewController: rootViewController,, coverImageName:, coverImageName,,框架:,CGRect.init(产地:,tool.origin,,尺寸:,CGSize.init(宽度:radious,,身高:,radious)))   ,window.show ()   ,tool.suspendWindows.append(窗口)   ,}      ,static  func  replaceSuspendWindow (rootViewController:,, ui, coverImageName:,字符串),{   ,let  tool =SuspendTool.sharedInstance   ,tool.suspendWindows.removeAll ()   ,let  window =, SuspendWindow.init (rootViewController: rootViewController,, coverImageName:, coverImageName,,框架:,CGRect.init(产地:,tool.origin,,尺寸:,CGSize.init(宽度:radious,,身高:,radious)))   ,window.show ()   ,tool.suspendWindows.append(窗口)   ,}      ,static  func  remove (suspendWindow: suspendWindow), {   0.25,UIView.animate (withDuration:,,,动画:,{   suspendWindow.alpha 才能=0   ,}){,(完成)   if 才能let  index =, SuspendTool.sharedInstance.suspendWindows.index (:, suspendWindow), {   SuspendTool.sharedInstance.suspendWindows.remove才能(:,指数)   ,,}   ,}   ,}      ,static  func  setLatestOrigin(产地:,CGPoint), {=,SuspendTool.sharedInstance.origin 起源   ,}   }

SuspendWindow

import  UIKit      let  radious: CGFloat =, 82      class  SuspendWindow:, UIWindow  {   ,   ,fileprivate  let  coverImageName:字符串   ,fileprivate  let 空间:CGFloat =15   ,var  containsRootViewController: ui ?   ,   ,init (rootViewController: UIViewController , coverImageName:,字符串,框架:,CGRect中),{   self.coverImageName 才能=coverImageName   super.init才能(框架:框架)//才能,self.rootViewController =rootViewController   self.containsRootViewController 才能=rootViewController   ,}   ,   init, required  ? (coder  aDecoder:, NSCoder), {   ,,fatalError (“init(编码器:),has  not  been  implemented")   ,}   ,   ,func 显示(),{   self.backgroundColor 才能=UIColor.clear   self.windowLevel 才能=,UIWindow.Level.alert 作用;1//UIWindowLevelAlert 作用;1   self.screen 才能=UIScreen.main   self.isHidden 才能=false   ,,   let 才能;bgView =, UIView ()   bgView.isUserInteractionEnabled 才能=,真的   bgView.frame 才能=self.bounds   bgView.backgroundColor 才能=UIColor.white   bgView.layer.cornerRadius 才能=,radious /2.0   bgView.layer.borderColor 才能=UIColor.lightGray.cgColor   bgView.layer.borderWidth 才能=5   bgView.layer.masksToBounds 才能=,真的   self.addSubview才能(bgView)   bgView.addSubview才能(iconImageView)   bgView.addSubview才能(timeLabel)   ,,   let 才能;panGesture =, UIPanGestureRecognizer.init(目标:自我,,行动:,#选择器(didPan (_:)))   self.addGestureRecognizer才能(panGesture)   ,,   let 才能;tapGesture =, UITapGestureRecognizer.init(目标:自我,,行动:,#选择器(didTap (_:)))   self.addGestureRecognizer才能(tapGesture)   ,}   ,   ,@objc  fileprivate  func  didTap (_  tapGesture:, UITapGestureRecognizer), {   SuspendTool.sharedInstance.origin 才能=self.frame.origin   self.containsRootViewController才能? .spread (:, self.self.frame.origin)   SuspendTool.remove才能(suspendWindow:自我)   ,}   ,   ,@objc  fileprivate  func  didPan (_  panGesture:, UIPanGestureRecognizer), {   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

使用Swift怎么实现一个最小化语音通话功能