8000 GitHub - unmute/VolumeBar: 📣 Volume indicator that doesn't obstruct content.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

unmute/VolumeBar

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VolumeBar

VolumeBar

VolumeBar is a Swift volume indicator that doesn't obstruct content on screen. A basic implementation is just one line of code, but it can be heavily customized via several appearance and presentation properties.

Features

  • Customizable appearance
  • Orientation change support
  • Hides system volume HUD automatically
  • Simple API

Build Status Pod Version

Version Compatibility

Current Swift compatibility breakdown:

Swift Version Framework Version
3.0 master
2.3 1.1
2.2 1.1

Usage

A basic implementation of VolumeBar is just one line of code.

VolumeBar.sharedInstance.start()

By default, adding VolumeBar to your app will cause background audio to pause when your app is opened. To prevent this, add the following line of code wherever you call the start method:

try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)

Calling the start method begins observing changes in the system volume. After calling start, VolumeBar will show automatically whenever your app is active and the volume changes. This is appropriate for most use cases. To stop observing changes and use the system volume HUD again, call stop:

VolumeBar.sharedInstance.stop()

Please see the documentation and check out the sample app (VolumeBarSample) for more details.


Appearance

Customize tint color, bar tint color, and track tint color:

VolumeBar.sharedInstance.tintColor = UIColor.white
VolumeBar.sharedInstance.backgroundColor = UIColor.black.withAlphaComponent(0.5)
VolumeBar.sharedInstance.trackTintColor = UIColor.clear

Customize layout properties:

VolumeBar.sharedInstance.barHeight = 5
VolumeBar.sharedInstance.segmentCount = 8
VolumeBar.sharedInstance.interitemSpacing = 5

Presentation

If start has been called, VolumeBar will automatically show when the system volume changes. You can also manually show and hide VolumeBar.

VolumeBar.sharedInstance.show()
VolumeBar.sharedInstance.hide()

Change the animation style:

VolumeBar.sharedInstance.animationStyle = .fade // default is .slide
VolumeBar.sharedInstance.animationDuration = 0.5
VolumeBar.sharedInstance.minimumVisibleDuration = 2.0

Status Bar

VolumeBar needs to know when the status bar is hidden or changes style. These properties should be updated in the viewWillAppear method of each view controller.

VolumeBar.sharedInstance.statusBarHidden = false
VolumeBar.sharedInstance.statusBarStyle = .lightContent

Installation

CocoaPods

VolumeBar is available using the Cocoa dependency manager CocoaPods.

To integrate, add the following to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'VolumeBar', '~> 2.0.4'

Carthage

Installation is also available using the dependency manager Carthage. To integrate, add the following line to your Cartfile:

github "gizmosachin/VolumeBar" "master"

Swift Package Manager

Installation is also available using the Swift Package Manager. To integrate, add the following to your Package.swift:

import PackageDescription

let package = Package(
    name: "MyProject",
    dependencies: [
        .Package(url: "https://github.com/gizmosachin/VolumeBar.git", majorVersion: 0),
    ]
)

Manual

You can also simply copy VolumeBar.swift into your Xcode project.

Documentation

API documentation is available here.

Community

License

VolumeBar is available under the MIT license, see the LICENSE file for more information.

About

📣 Volume indicator that doesn't obstruct content.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.0%
  • Ruby 3.1%
  • Shell 2.9%
0