支持动态检测屏幕亮度的功能源码,源码ASCScreenBrightnessDetector,可以动态检测屏幕亮度,提供delegate函数来即时响应屏幕亮度的变化。喜欢的朋友可以下载研究一下吧,ios源码频道提供下载。
ASCScreenBrightnessDetector
ASCScreenBrightnessDetector lets you easily detect screen brightness changes and provides some useful delegate methods.
For Example it is very easy to switch between a day and night theme optimized for different lighting conditions:
使用方法:
检测当前屏幕亮度:
ASCScreenBrightnessDetector *brightnessDetector = [ASCScreenBrightnessDetector new];
NSLog(@"Screen brightness: %f", brightnessDetector.screenBrightness);
ASCScreenBrightnessStyle style = brightnessDetector.screenBrightnessStyle;
switch (style) {
case ASCScreenBrightnessStyleDark:
// Do something, e.g. set a dark theme.
break;
case ASCScreenBrightnessStyleLight:
// Do something else, e.g set a light theme.
break;
}
响应屏幕亮度变化的delegate函数:
- (void)screenBrightnessDidChange:(CGFloat)brightness
{
NSLog(@"The new brightness is: %f", brightness);
}
- (void)screenBrightnessStyleDidChange:(ASCScreenBrightnessStyle)style
{
NSLog(@"The new style is: %u", style);
}
2021-04-03 12:10:01
51KB
IOS源码
1