|
|
@@ -0,0 +1,292 @@
|
|
|
+//
|
|
|
+// YRWorkTabCell.m
|
|
|
+// UU_Ent
|
|
|
+//
|
|
|
+// Created by liujl on 2019/4/30.
|
|
|
+// Copyright © 2019 UAS. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "YRWorkTabCell.h"
|
|
|
+#import "YRWorkCollCell.h"
|
|
|
+
|
|
|
+@interface YRWorkTabCell()<UICollectionViewDelegate,UICollectionViewDataSource>
|
|
|
+
|
|
|
+@property(strong,nonatomic)UIView *header;
|
|
|
+
|
|
|
+@property(strong,nonatomic)UILabel *titleLabel;
|
|
|
+
|
|
|
+@property(strong,nonatomic)UICollectionView *collView;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation YRWorkTabCell
|
|
|
+
|
|
|
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
|
|
+
|
|
|
+ if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
+
|
|
|
+ [self setUpUI];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return self;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(void)setUpUI{
|
|
|
+
|
|
|
+ self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
+
|
|
|
+ self.layer.cornerRadius = 10;
|
|
|
+
|
|
|
+ self.layer.masksToBounds = YES;
|
|
|
+
|
|
|
+ [self.contentView addSubview:self.header];
|
|
|
+
|
|
|
+ [self.header mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.top.equalTo(self.contentView).offset(8);
|
|
|
+ make.width.mas_equalTo(6);
|
|
|
+ make.left.equalTo(self.contentView);
|
|
|
+ make.height.mas_equalTo(16);
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.contentView addSubview:self.titleLabel];
|
|
|
+ [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.top.equalTo(self.header);
|
|
|
+ make.left.equalTo(self.header.mas_right).offset(3);
|
|
|
+ make.height.equalTo(self.header);
|
|
|
+ make.right.equalTo(self.contentView);
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.contentView addSubview:self.collView];
|
|
|
+
|
|
|
+ [self.collView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ make.left.right.equalTo(self.contentView);
|
|
|
+ make.top.equalTo(self.header.mas_bottom);
|
|
|
+ make.bottom.equalTo(self.contentView).offset(-8);
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
|
|
+
|
|
|
+ return 1;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
|
+
|
|
|
+
|
|
|
+ return 3;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+
|
|
|
+
|
|
|
+ YRWorkCollCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YRWorkCollCellReid" forIndexPath:indexPath];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return cell;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+
|
|
|
+ return YES;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(UICollectionView *)collView{
|
|
|
+
|
|
|
+ if (!_collView) {
|
|
|
+
|
|
|
+ UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
|
|
|
+
|
|
|
+ flowLayout.itemSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width - 20)/4, 80);
|
|
|
+
|
|
|
+ flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
|
|
+ flowLayout.minimumLineSpacing = 0;
|
|
|
+ flowLayout.minimumInteritemSpacing = 0;
|
|
|
+
|
|
|
+ _collView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flowLayout];
|
|
|
+
|
|
|
+ _collView.delegate = self;
|
|
|
+ _collView.dataSource = self;
|
|
|
+ _collView.scrollEnabled = NO;
|
|
|
+
|
|
|
+ // UILongPressGestureRecognizer *longGes = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTouchBegin:)];
|
|
|
+ // [_collView addGestureRecognizer:longGes];
|
|
|
+
|
|
|
+ _collView.backgroundColor = [UIColor whiteColor];
|
|
|
+ [_collView registerClass:[YRWorkCollCell class] forCellWithReuseIdentifier:@"YRWorkCollCellReid"];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return _collView;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)longTouchBegin:(UILongPressGestureRecognizer *)longGes{
|
|
|
+
|
|
|
+// if (self.moveBegin) {
|
|
|
+//
|
|
|
+// CGPoint point = [longGes locationInView:self.collView];
|
|
|
+//
|
|
|
+// NSIndexPath *indexpath = [self.collView indexPathForItemAtPoint:point];
|
|
|
+//
|
|
|
+// UASWorkMainCell *cell = (UASWorkMainCell *)[self.collView cellForItemAtIndexPath:indexpath];
|
|
|
+//
|
|
|
+// self.moveBegin(longGes,cell,self.collView,self.section);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// switch (longGes.state) {
|
|
|
+// case UIGestureRecognizerStateBegan:{
|
|
|
+//
|
|
|
+// CGPoint point = [longGes locationInView:self.collView];
|
|
|
+//
|
|
|
+// NSIndexPath *indexpath = [self.collView indexPathForItemAtPoint:point];
|
|
|
+//
|
|
|
+// [self.collView beginInteractiveMovementForItemAtIndexPath:indexpath];
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// break;
|
|
|
+//
|
|
|
+// case UIGestureRecognizerStateChanged:{
|
|
|
+//
|
|
|
+// CGPoint point = [longGes locationInView:self.collView];
|
|
|
+//
|
|
|
+// self.imageView.center = point;
|
|
|
+//
|
|
|
+// [self.collView updateInteractiveMovementTargetPosition:point];
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// break;
|
|
|
+// case UIGestureRecognizerStateEnded:{
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.collView endInteractiveMovement];
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// break;
|
|
|
+//
|
|
|
+//
|
|
|
+// case UIGestureRecognizerStateCancelled:{
|
|
|
+//
|
|
|
+// [self.collView endInteractiveMovement];
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// break;
|
|
|
+//
|
|
|
+//
|
|
|
+// case UIGestureRecognizerStatePossible:{
|
|
|
+//
|
|
|
+//
|
|
|
+// break;
|
|
|
+//
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// break;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+}
|
|
|
+
|
|
|
+- (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath{
|
|
|
+
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+//
|
|
|
+// if (sourceIndexPath.row < destinationIndexPath.row) {
|
|
|
+// //终点cell之前的元素前移
|
|
|
+// for (NSInteger i = sourceIndexPath.row; i<destinationIndexPath.row; i++) {
|
|
|
+//
|
|
|
+// UASWorkMainModel *temp = self.secModel.modelArr[i];
|
|
|
+// self.secModel.modelArr[i] = self.secModel.modelArr[i+1];
|
|
|
+// self.secModel.modelArr[i+1] = temp;
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }else{
|
|
|
+//
|
|
|
+// for (NSInteger i = sourceIndexPath.row; i>destinationIndexPath.row; i--) {
|
|
|
+//
|
|
|
+// UASWorkMainModel *temp = self.secModel.modelArr[i];
|
|
|
+// self.secModel.modelArr[i] = self.secModel.modelArr[i-1];
|
|
|
+// self.secModel.modelArr[i-1] = temp;
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// [self.collView reloadData];
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(UILabel *)titleLabel{
|
|
|
+
|
|
|
+ if (!_titleLabel) {
|
|
|
+
|
|
|
+ _titleLabel = [UILabel new];
|
|
|
+ _titleLabel.backgroundColor = [UIColor whiteColor];
|
|
|
+ _titleLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return _titleLabel;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+-(UIView *)header{
|
|
|
+
|
|
|
+ if (!_header) {
|
|
|
+
|
|
|
+ _header =[[UIView alloc]init];
|
|
|
+
|
|
|
+ _header.backgroundColor = [UIColor blackColor];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return _header;
|
|
|
+
|
|
|
+}
|
|
|
+@end
|