zoukankan      html  css  js  c++  java
  • 支付宝付款页面调整屏幕亮度

    方法很简单:

                [UIScreen mainScreen].brightness = 0-1(屏幕亮度范围);
    但是对眼睛伤害不利;采用逐渐变亮的方法:


    //

    //  ScreenBrightness.h

    //  Jump

    //

    //  Created by peter.zhang on 2017/4/24.

    //  Copyright © 2017年 redstar. All rights reserved.

    //

    #import <Foundation/Foundation.h>

    @interface ScreenBrightness : NSObject

    - (void)graduallyResumeBrightness:(CGFloat)brightness;

    @end




    //

    //  ScreenBrightness.m

    //  Jump

    //

    //  Created by peter.zhang on 2017/4/24.

    //  Copyright © 2017年 redstar. All rights reserved.

    //

    #import "ScreenBrightness.h"

    @interface ScreenBrightness()

    @property (nonatomic, strong)NSOperationQueue *queue;

    @property (nonatomic, assign)CGFloat currentBrightness;

    @end

    @implementation ScreenBrightness

    - (instancetype)init{

        self = [super init];

        if (self) {

            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveDefaultBrightness) name:UIScreenBrightnessDidChangeNotification object:nil];

            [self saveDefaultBrightness];

        }

        return self;

    }

    - (void)graduallySetBrightness:(CGFloat)value{

        if (!_queue) {

            _queue = [[NSOperationQueue alloc] init];

            _queue.maxConcurrentOperationCount = 1;

        }

        [_queue cancelAllOperations];

        

        CGFloat brightness = [UIScreen mainScreen].brightness;

        CGFloat step = 0.005 * ((value > brightness) ? 1 : -1);

        int times = fabs((value - brightness) / 0.005);

        for (CGFloat i = 1; i < times + 1; i++) {

            [_queue addOperationWithBlock:^{

                [NSThread sleepForTimeInterval:1 / 180.0];

                [UIScreen mainScreen].brightness = brightness + i * step;

            }];

        }

    }

    - (void)saveDefaultBrightness{

        _currentBrightness = [UIScreen mainScreen].brightness;

    }

    - (void)graduallyResumeBrightness:(CGFloat)brightness{

        [self graduallySetBrightness:brightness];

    }

    @end


     

  • 相关阅读:
    WIN10X64LTSC2019中度精简版by双心
    MACbook安装WIN7后亮度调节的办法
    MACbook安装WIN7中文版后乱码的解决办法
    MACbook关机开机的咚咚咚声音
    MacBook安装WIN7开机黑屏的解决办法
    小马激活的问题
    安装WIN7系统备忘录
    win7 64位平台编译的程序在XP 32位平台无法运行的解决方法
    for循环包含多个双引号怎么办?windows
    windows下sed回车换行符处理
  • 原文地址:https://www.cnblogs.com/PeterWolf/p/6757524.html
Copyright © 2011-2022 走看看