ResultCell.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // ResultCell.m
  3. // Apex Mobile
  4. //
  5. // Created by Jack on 2018/2/14.
  6. // Copyright © 2018年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ResultCell.h"
  9. @implementation ResultCell
  10. {
  11. UIColor *_normalBGColor;
  12. }
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. // Initialization code
  16. }
  17. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  18. [super setSelected:selected animated:animated];
  19. // Configure the view for the selected state
  20. }
  21. - (void)touch:(NSSet<UITouch *> *)touches {
  22. if (self.handlingTouch) {
  23. return;
  24. }
  25. UITouch *touch = [[touches allObjects] lastObject];
  26. if (self.touchDelegate && [self.touchDelegate respondsToSelector:@selector(touchedCell:withForce:)]) {
  27. [self.touchDelegate touchedCell:self withForce:touch.force];
  28. }
  29. }
  30. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  31. if (self.touchColor) {
  32. _normalBGColor = self.backgroundColor;
  33. self.backgroundColor = self.touchColor;
  34. }
  35. [super touchesBegan:touches withEvent:event];
  36. self.handlingTouch = NO;
  37. [self touch:touches];
  38. }
  39. - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  40. [super touchesMoved:touches withEvent:event];
  41. [self touch:touches];
  42. }
  43. - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  44. self.backgroundColor = _normalBGColor;
  45. [super touchesEnded:touches withEvent:event];
  46. [self touch:touches];
  47. }
  48. - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  49. self.backgroundColor = _normalBGColor;
  50. [super touchesCancelled:touches withEvent:event];
  51. [self touch:touches];
  52. }
  53. @end