m (→Example usage) |
m (It's actually CGFloat.) |
||
Line 11: | Line 11: | ||
{{function signature | {{function signature | ||
|signature=-(BOOL)setFlashlightLevel:( | |signature=-(BOOL)setFlashlightLevel:(CGFloat)level withError:(NSError *)error; | ||
|firmware=7.0 — | |firmware=7.0 — | ||
}} | }} | ||
Line 24: | Line 24: | ||
... | ... | ||
// Make sure you don't have any other AVFlashlight object instantiated | // Make sure you don't have any other AVFlashlight object instantiated, or this flashlight won't be functional. | ||
if ([AVFlashlight hasFlashlight]) { | if ([AVFlashlight hasFlashlight]) { | ||
flashlight = [AVFlashlight new]; | flashlight = [AVFlashlight new]; | ||
[flashlight setFlashlightLevel: | [flashlight setFlashlightLevel:1.0f withError:nil]; | ||
} | } | ||
Revision as of 12:17, 3 March 2015
AVFlashlight is a private class introduced in iOS 7 for turning the device's LED flash on or off. The example application that uses this class is Control Center in SpringBoard.
Methods
Signature | +(BOOL)hasFlashlight; |
---|---|
Available in | 7.0 — |
The method +[AVFlashlight hasFlashlight] indicates the LED flash availability.
Signature | -(BOOL)setFlashlightLevel:(CGFloat)level withError:(NSError *)error; |
---|---|
Available in | 7.0 — |
The method -[AVFlashlight setFlashlightLevel:withError:] is used for setting the flashlight level.
Example usage
static AVFlashlight *flashlight;
...
// Make sure you don't have any other AVFlashlight object instantiated, or this flashlight won't be functional.
if ([AVFlashlight hasFlashlight]) {
flashlight = [AVFlashlight new];
[flashlight setFlashlightLevel:1.0f withError:nil];
}
...
// Do this when you want to turn power/light off the LED flash
[flashlight turnPowerOff];
|