2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
962 B

  1. //
  2. // SCFlashButton.m
  3. // SCCamera
  4. //
  5. // Created by Will Wu on 2/13/14.
  6. // Copyright (c) 2014 Snapchat, Inc. All rights reserved.
  7. //
  8. #import "SCFlashButton.h"
  9. #import <SCUIKit/SCPixelRounding.h>
  10. @implementation SCFlashButton
  11. - (void)setButtonState:(SCFlashButtonState)buttonState
  12. {
  13. // Don't reset flash button state if it doesn't change.
  14. if (_buttonState == buttonState) {
  15. return;
  16. }
  17. _buttonState = buttonState;
  18. if (buttonState == SCFlashButtonStateOn) {
  19. self.image = [UIImage imageNamed:@"camera_flash_on_v10"];
  20. self.accessibilityValue = @"on";
  21. } else {
  22. self.image = [UIImage imageNamed:@"camera_flash_off_v10"];
  23. self.accessibilityValue = @"off";
  24. }
  25. self.imageInset = SCRoundSizeToPixels(CGSizeMake((CGRectGetWidth(self.bounds) - self.image.size.width) / 2,
  26. (CGRectGetHeight(self.bounds) - self.image.size.height) / 2));
  27. }
  28. @end