口袋优选

KBCollectionView.m 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // KBCollectionView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/17.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBCollectionView.h"
  9. @implementation KBCollectionView
  10. - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
  11. self = [super initWithFrame:frame collectionViewLayout:layout];
  12. if (self) {
  13. self.delaysContentTouches = NO;
  14. self.canCancelContentTouches = YES;
  15. self.backgroundView.backgroundColor = [UIColor clearColor];
  16. self.backgroundColor = [UIColor clearColor];
  17. UIView *wrapView = self.subviews.firstObject;
  18. if (wrapView && [NSStringFromClass(wrapView.class) hasSuffix:@"WrapperView"]) {
  19. for (UIGestureRecognizer *gesture in wrapView.gestureRecognizers) {
  20. if ([NSStringFromClass(gesture.class) containsString:@"DelayedTouchesBegan"]) {
  21. gesture.enabled = NO;
  22. break;
  23. }
  24. }
  25. }
  26. }
  27. return self;
  28. }
  29. - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
  30. if ([view isKindOfClass:[UIControl class]]) {
  31. return YES;
  32. }
  33. return [super touchesShouldCancelInContentView:view];
  34. }
  35. @end