12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- // AddGroupLabelVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/5/8.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "AddGroupLabelVC.h"
- #import "TDGroupLabelCell.h"
- @interface AddGroupLabelVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITextFieldDelegate>
- @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
- @property (weak, nonatomic) IBOutlet UIButton *doneBtn;
- @property (weak, nonatomic) IBOutlet UITextField *textField;
- @property (weak, nonatomic) IBOutlet UIButton *addBtn;
- @end
- @implementation AddGroupLabelVC
- +(AddGroupLabelVC *)initAddGroupLabelVC{
- AddGroupLabelVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"AddGroupLabelVC"];
- controller.modalPresentationStyle = UIModalPresentationFullScreen;
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.collectionView.delegate = self;
- self.collectionView.dataSource = self;
- [self.collectionView setCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
- self.collectionView.showsVerticalScrollIndicator = NO;
- self.collectionView.showsHorizontalScrollIndicator = NO;
- self.collectionView.contentInset = UIEdgeInsetsMake(24, 30, 0, 24);
- [self.collectionView registerNib:[UINib nibWithNibName:@"TDGroupLabelCell" bundle:nil] forCellWithReuseIdentifier:@"TDGroupLabelCell"];
- self.collectionView.backgroundColor = [UIColor whiteColor];
- self.textField.returnKeyType = UIReturnKeyDone;
- self.textField.delegate = self;
- [self.collectionView reloadData];
- WS(weakSelf);
- [self.addBtn setAction:^{
- [weakSelf.textField resignFirstResponder];
- }];
- [self.doneBtn setAction:^{
- [weakSelf dismissViewControllerAnimated:YES completion:^{
-
- }];
- }];
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
- [self.textField resignFirstResponder];
- return YES;
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return 6;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- return CGSizeMake((SCREEN_WIDTH - 63) * 0.5, 58.f);
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
- {
- return 7.f;
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
- {
- return 9.f;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- TDGroupLabelCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TDGroupLabelCell" forIndexPath:indexPath];
- cell.titleL.text = @"语文作文";
- cell.deleteBtn.hidden = NO;
- [cell.deleteBtn setAction:^{
- NSLog(@"deleteBtn");
- }];
- return cell;
- }
- @end
|