我正在尝试将打开的ios应用默认为特定的亮度。这可能吗?如果是这样,我需要使用哪些软件包?
如果无法实现,我可以在应用程序本身中使用亮度滚动条吗?
谢谢!
答案 0 :(得分:2)
要设置屏幕亮度,请尝试以下代码
UIScreen.main.brightness = CGFloat(0.5)
答案 1 :(得分:0)
您可以查看this文章。
import UIKit
extension UIScreen
{
static func setMainBrightness(brightness: CGFloat)
{
guard (0...1).contains(brightness) else
{
print("Attempt to set the screen brightness to an invalid value: \(brightness) should be between 0 and 1 inclusive.")
return
}
self.main.brightness = brightness
}
}