你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS偽亮度調節/控制

iOS偽亮度調節/控制

編輯:IOS開發綜合

iOS並沒有開放控制系統亮度的接口,所以app能做到的只是比系統設置的亮度更暗,具體做法就是在整個app的keywindow之上再放一個window,設置黑色背景,通過控制alpha值來達到明暗變化。


[cpp]
- (void)installBrightnessWindow 

    m_brightnessWindow = [[UIWindow alloc] initWithFrame:self.view.window.frame]; 
    m_brightnessWindow.windowLevel = UIWindowLevelStatusBar + 1; 
    m_brightnessWindow.userInteractionEnabled = NO; 
    m_brightnessWindow.backgroundColor = [UIColor blackColor]; 
    m_brightnessWindow.alpha = 0; 
    m_brightnessWindow.hidden = NO; 

- (void)installBrightnessWindow
{
    m_brightnessWindow = [[UIWindow alloc] initWithFrame:self.view.window.frame];
    m_brightnessWindow.windowLevel = UIWindowLevelStatusBar + 1;
    m_brightnessWindow.userInteractionEnabled = NO;
    m_brightnessWindow.backgroundColor = [UIColor blackColor];
    m_brightnessWindow.alpha = 0;
    m_brightnessWindow.hidden = NO;
}

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved