ScreenBrightness 1.1.0

ScreenBrightness 1.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by Michal Konturek.



ScreenBrightness

ScreenBrightness allows you to monitor brightness of your device screen without a hassle.

Example

To run the example project, clone the repo, and run pod install from the Example directory first. Alternatively, you could run the demo by executing pod try ScreenBrightness in your terminal.

NB Screen brigthness of iOS simulators is always 0.5, so make sure you run it on a real device.

Demo

Usage

To start, simply import ScreenBrightness to your project

import ScreenBrightness

and initialize ScreenBrightness class, set its delegate

let screenBrightness = ScreenBrightness(screen: UIScreen.mainScreen())
screenBrightness.delegate = self

and then implement screenBrightnessDidChange method to start monitoring screen brightness changes.

func screenBrightnessDidChange() {
    print(screenBrightness.brightness)
    print(screenBrightness.isLight)
}

Properties

public weak var delegate: ScreenBrightnessMonitoring?

A delegate that conforms to ScreenBrightnessMonitoring protocol.

public var brightness: CGFloat

Returns screen brightness value.

public var isLight: Bool

Returns true if screen brightness is greater than defined threshold.

public var threshold: Float

Determines if brightness is ligt or dark. Default value is 0.5.

Installation

ScreenBrightness is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ScreenBrightness"

License

ScreenBrightness is available under the MIT license. See the LICENSE file for more info.

Credits

Thsis repository is inspired by ASCScreenBrightnessDetector by André Schneider.