Latest 0.1.0
Homepage https://github.com/silence0201/ScreenBrightnessObserver
License MIT
Platforms ios 5.0, requires ARC
Authors

ScreenBrightnessObserver

Language
License

一个简单的屏幕亮度观察,可以用来做简单的主题切换

导入

将项目中ScreenBrightnessObserver文件夹拖到项目里

或者使用Pod安装

pod 'SIScreenBrightnessObserver', '~> 0.1.0'    

使用

  1. 导入头文件

    #import "SIScreenBrightnessObserver.h"
  2. 保留观察者对象

    @implementation ViewController{
        SIScreenBrightnessObserver *_observer ; // 需要对这个对象进行引用,否则释放后不能进行监听
    }
  3. 初始化

    _observer = [[SIScreenBrightnessObserver alloc]init] ; // 以MainScreen初始化
    _observer.delegate = self ; // 设置代理
    _observer.threshold = 0.4 ; // 设置门槛
  4. 实现代理方法或监听通知

    // 当屏幕亮度发生改变时调用
    - (void)screenBrightnessDidChange:(CGFloat)brightness{
        self.brightnessLabel.text = [NSString stringWithFormat:@"%.2f",brightness] ;
    }
    
    // 当屏幕亮度主题发生改变时
    - (void)screenBrightnessStyleDidChange:(SIScreenBrightnessStyle)style{
        if (style == SIScreenBrightnessDark) {
            self.StyleLabel.text = @"Dark" ;
        }else{
            self.StyleLabel.text = @"Light" ;
        }
    }

ScreenBrightnessObserver

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

Latest podspec

{
    "name": "SIScreenBrightnessObserver",
    "version": "0.1.0",
    "summary": "A ScreenBrightnessObserver.",
    "description": "A ScreenBrightness Observer",
    "homepage": "https://github.com/silence0201/ScreenBrightnessObserver",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Silence": "[email protected]"
    },
    "social_media_url": "https://twitter.com/Silencee0201",
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/silence0201/ScreenBrightnessObserver.git",
        "tag": "0.1.0"
    },
    "source_files": [
        "ScreenBrightnessObserver",
        "ScreenBrightnessObserver/**/*.{h,m}"
    ],
    "exclude_files": "ScreenBrightnessObserver/Exclude",
    "public_header_files": "ScreenBrightnessObserver/**/*.h",
    "requires_arc": true
}

Pin It on Pinterest

Share This