Latest 1.1.0
Homepage https://github.com/michalkonturek/ScreenBrightness
License MIT
Platforms ios 8.0
Authors

Version
Build Status
Swift
Platform
License
Twitter

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.

Latest podspec

{
    "name": "ScreenBrightness",
    "version": "1.1.0",
    "summary": "ScreenBrightness allows you to monitor brightness of your device screen without a hassle.",
    "homepage": "https://github.com/michalkonturek/ScreenBrightness",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Michal Konturek": "[email protected]"
    },
    "source": {
        "git": "https://github.com/michalkonturek/ScreenBrightness.git",
        "tag": "1.1.0"
    },
    "social_media_url": "https://twitter.com/michalkonturek",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ScreenBrightness/Classes/**/*"
}

Pin It on Pinterest

Share This