iPhone 5's low light boost mode

2019-07-20 20:06发布

问题:

Has anyone been able to get the iPhone 5's new low light boost mode to work in their custom camera app? I tried the following code, but noticed no difference - whereas the native camera app significantly boosted the brightness.

if ([[captureManager backFacingCamera] isLowLightBoostEnabled]) {

    [[captureManager backFacingCamera] automaticallyEnablesLowLightBoostWhenAvailable];
}

回答1:

You need to lockForConfiguration, according to the docs (well, the header file):

if ([[self backFacingCamera] respondsToSelector:@selector(isLowLightBoostSupported)]) {
  if ([[self backFacingCamera] lockForConfiguration:nil]) {
    if ([self backFacingCamera].isLowLightBoostSupported)
      [self backFacingCamera].automaticallyEnablesLowLightBoostWhenAvailable = YES;
    [[self backFacingCamera] unlockForConfiguration];
  }
}

Also, isLowLightBoostEnabled tells you whether or not the low light is actually being boosted, not whether it can be. That's the isLowLightBoostSupported selector, as above (to which only iOS 6 devices respond).