YFVolumeView 1.1.0

YFVolumeView 1.1.0

测试已测试
Lang语言 SwiftSwift
许可证 Apache-2.0
发布最新发布2023年1月
SwiftSwift 版本3.0
SPM支持 SPM

Yurii Lysytsia 维护。



  • 作者:
  • Yuri Fox

YFVolumeView

Swift 3 编写的便捷、美观且易于使用的音量指示器

要求

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3.0+

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

需要 cocoaPods 1.1.0+ 版本才能构建。

要使用 CocoaPods 在您的 Xcode 项目中集成 YFVolumeView,创建 Podfile。在您的项目根目录中运行以下命令

$ pod init

在出现的 Podfile 中,指定

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘8.0
use_frameworks!

target '<Your Target Name>' do
	pod 'YFVolumeView'
end

然后,运行以下命令

$ pod install

使用方法

在你的项目AppDelegate.swift中

import YFVolumeView

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    ...
    
    func setVolumeIndicator() {
        
        let volumeIndicator = YFVolumeView.current
        volumeIndicator.isActive = true // Make active YFVolumeView and hide native HUD
        volumeIndicator.backgroundColor = .white // Set custom background color
        
//        if let window = self.window {
//            volumeIndicator.setBackgroundColorAsWindowWithRootNavigationBar(window: window)
//            // If AppDelegate.window.rootViewController is UINavigationController, volume indicator color will be as UINavigationController.navigationBar.barTintColor
//        }


    }

    ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        ...
        
        self.setVolumeIndicator()
        
        ...

        return true
    }
    
    ...
    
}