ResultCell.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. @interface ResultCell ()
  10. @property (nonatomic,assign) BOOL handlingTouch;
  11. @end
  12. @implementation ResultCell
  13. {
  14. UIColor *_normalBGColor;
  15. }
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. - (void)touch:(NSSet<UITouch *> *)touches {
  25. if (self.handlingTouch) {
  26. return;
  27. }
  28. UITouch *touch = [[touches allObjects] lastObject];
  29. if (self.touchDelegate && [self.touchDelegate respondsToSelector:@selector(touchedCell:withForce:)]) {
  30. self.handlingTouch = YES;
  31. [self.touchDelegate touchedCell:self withForce:touch.force];
  32. }
  33. }
  34. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  35. if (self.touchColor) {
  36. _normalBGColor = self.backgroundColor;
  37. self.backgroundColor = self.touchColor;
  38. }
  39. // [super touchesBegan:touches withEvent:event];
  40. self.handlingTouch = NO;
  41. [self touch:touches];
  42. }
  43. - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  44. // [super touchesMoved:touches withEvent:event];
  45. [self touch:touches];
  46. }
  47. - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  48. self.backgroundColor = _normalBGColor;
  49. // [super touchesEnded:touches withEvent:event];
  50. [self touch:touches];
  51. }
  52. - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  53. self.backgroundColor = _normalBGColor;
  54. // [super touchesCancelled:touches withEvent:event];
  55. [self touch:touches];
  56. }
  57. @end