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


     

  • 相关阅读:
    forever守护nodejs
    sql server自动备份
    mongodb数据库自动备份 windows
    mongodb中的objectId和字符串id之间的转换
    mongodb中内嵌数组的增删改查
    nodejs momentjs操作时间(24小时制)
    nodejs 获取某一时间的前一天 后一天
    FastDFS 文件上传成功,访问404
    Ubuntu16.04系统下FastDFS+Nginx安装配置
    ubuntu16.04安装python3.7
  • 原文地址:https://www.cnblogs.com/PeterWolf/p/6757524.html
Copyright © 2011-2022 走看看