### Support iPhone Notch Area Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Example implementation for positioning the volume bar in the notch area of iPhone X devices. ```swift class ViewController: UIViewController { let volume = SubtleVolume(style: .rounded) var statusBarVisible = true // ... override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if view.safeAreaInsets.top > 0 { volume.padding = CGSize(width: 2, height: 8) volume.frame = CGRect(x: 16, y: 8, width: 60, height: 20) } else { // older phones here } } override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { return .slide } override var prefersStatusBarHidden: Bool { return !statusBarVisible } } extension ViewController: SubtleVolumeDelegate { func subtleVolume(_ subtleVolume: SubtleVolume, didChange value: Double) { if !subtleVolume.isAnimating && view.safeAreaInsets.top > 0 { statusBarVisible = true UIView.animate(withDuration: 0.1) { self.setNeedsStatusBarAppearanceUpdate() } } } func subtleVolume(_ subtleVolume: SubtleVolume, willChange value: Double) { if !subtleVolume.isAnimating && view.safeAreaInsets.top > 0 { statusBarVisible = false UIView.animate(withDuration: 0.1) { self.setNeedsStatusBarAppearanceUpdate() } } } } ``` -------------------------------- ### Initialize SubtleVolume Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Create a SubtleVolume instance and define its frame or layout constraints. ```swift let volume = SubtleVolume(style: .plain) volume.frame = CGRect(x: 0, y: 10, width: UIScreen.main.bounds.width, height: 4) // or wherever you like ``` -------------------------------- ### Implement Accessory Image Delegate Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Provide an image to display on the left side of the volume bar based on the current volume level. ```swift func subtleVolume(_ subtleVolume: SubtleVolume, accessoryFor value: Double) -> UIImage? { return value > 0 ? #imageLiteral(resourceName: "volume-on.pdf") : #imageLiteral(resourceName: "volume-off.pdf") } ``` -------------------------------- ### Configure SubtleVolume Appearance Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Customize the bar color and animation behavior of the volume indicator. ```swift volume.barTintColor = .red ``` ```swift volume.animation = .slideDown ``` -------------------------------- ### Resume SubtleVolume session on app activation Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Register an observer for the UIApplicationDidBecomeActive notification to resume the volume session. The observer is automatically removed upon deinitialization. ```swift NotificationCenter.default.addObserver(volume, selector: #selector(SubtleVolume.resume), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) ``` -------------------------------- ### Programmatic Volume Control Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Adjust the volume level programmatically using direct setting or convenience methods. ```swift try? volume.setVolumeLevel(0.5) ``` ```swift try? volume.decreaseVolume(by: 0.2, animated: true) try? volume.increaseVolume(by: 0.2, animated: true) ``` -------------------------------- ### Add SubtleVolume to View Hierarchy Source: https://github.com/andreamazz/subtlevolume/blob/master/README.md Add the volume view to the parent view to enable the indicator. ```swift view.addSubview(volume) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.