53 lines
1.7 KiB
Objective-C
53 lines
1.7 KiB
Objective-C
//
|
|
// JXCategoryCollectionView.m
|
|
// UI系列测试
|
|
//
|
|
// Created by jiaxin on 2018/3/21.
|
|
// Copyright © 2018年 jiaxin. All rights reserved.
|
|
//
|
|
|
|
#import "JXCategoryCollectionView.h"
|
|
|
|
@interface JXCategoryCollectionView ()<UIGestureRecognizerDelegate>
|
|
@end
|
|
|
|
@implementation JXCategoryCollectionView
|
|
|
|
- (void)setIndicators:(NSArray<UIView<JXCategoryIndicatorProtocol> *> *)indicators {
|
|
for (UIView *indicator in _indicators) {
|
|
//先移除之前的indicator
|
|
[indicator removeFromSuperview];
|
|
}
|
|
|
|
_indicators = indicators;
|
|
|
|
for (UIView *indicator in indicators) {
|
|
[self addSubview:indicator];
|
|
}
|
|
}
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
|
|
for (UIView<JXCategoryIndicatorProtocol> *view in self.indicators) {
|
|
[self sendSubviewToBack:view];
|
|
}
|
|
}
|
|
|
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
|
if (self.gestureDelegate && [self.gestureDelegate respondsToSelector:@selector(categoryCollectionView:gestureRecognizerShouldBegin:)]) {
|
|
return [self.gestureDelegate categoryCollectionView:self gestureRecognizerShouldBegin:gestureRecognizer];
|
|
}
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
if (self.gestureDelegate && [self.gestureDelegate respondsToSelector:@selector(categoryCollectionView:gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]) {
|
|
return [self.gestureDelegate categoryCollectionView:self gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer];
|
|
}
|
|
return NO;
|
|
}
|
|
|
|
@end
|