UICustomSwitch.m 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. =======================================================================================
  3. Copyright (C) 2009-2011 id Software LLC, a ZeniMax Media company. All Right Reserved.
  4. This file is part of the DOOM Classic iOS v2.1 GPL Source Code.
  5. =======================================================================================
  6. */
  7. #import "UICustomSwitch.h"
  8. @implementation UICustomSwitch
  9. @synthesize on;
  10. - (void)setOn:(BOOL)turnOn;
  11. {
  12. on = turnOn;
  13. if (on)
  14. {
  15. [ self setHighlighted: YES ];
  16. }
  17. else
  18. {
  19. [ self setHighlighted: NO ];
  20. }
  21. }
  22. - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
  23. {
  24. [super touchesBegan:touches withEvent:event];
  25. [self setOn: !on ];
  26. }
  27. - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
  28. {
  29. [super touchesEnded:touches withEvent:event];
  30. if (on)
  31. {
  32. [ self setHighlighted: YES ];
  33. }
  34. else
  35. {
  36. [ self setHighlighted: NO ];
  37. }
  38. }
  39. @end