AddGroupLabelVC.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // AddGroupLabelVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/5/8.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "AddGroupLabelVC.h"
  9. #import "TDGroupLabelCell.h"
  10. @interface AddGroupLabelVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITextFieldDelegate>
  11. @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
  12. @property (weak, nonatomic) IBOutlet UIButton *doneBtn;
  13. @property (weak, nonatomic) IBOutlet UITextField *textField;
  14. @property (weak, nonatomic) IBOutlet UIButton *addBtn;
  15. @end
  16. @implementation AddGroupLabelVC
  17. +(AddGroupLabelVC *)initAddGroupLabelVC{
  18. AddGroupLabelVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"AddGroupLabelVC"];
  19. controller.modalPresentationStyle = UIModalPresentationFullScreen;
  20. return controller;
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.fd_prefersNavigationBarHidden = YES;
  25. self.collectionView.delegate = self;
  26. self.collectionView.dataSource = self;
  27. [self.collectionView setCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
  28. self.collectionView.showsVerticalScrollIndicator = NO;
  29. self.collectionView.showsHorizontalScrollIndicator = NO;
  30. self.collectionView.contentInset = UIEdgeInsetsMake(24, 30, 0, 24);
  31. [self.collectionView registerNib:[UINib nibWithNibName:@"TDGroupLabelCell" bundle:nil] forCellWithReuseIdentifier:@"TDGroupLabelCell"];
  32. self.collectionView.backgroundColor = [UIColor whiteColor];
  33. self.textField.returnKeyType = UIReturnKeyDone;
  34. self.textField.delegate = self;
  35. [self.collectionView reloadData];
  36. WS(weakSelf);
  37. [self.addBtn setAction:^{
  38. [weakSelf.textField resignFirstResponder];
  39. }];
  40. [self.doneBtn setAction:^{
  41. [weakSelf dismissViewControllerAnimated:YES completion:^{
  42. }];
  43. }];
  44. }
  45. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  46. {
  47. [self.textField resignFirstResponder];
  48. return YES;
  49. }
  50. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  51. return 1;
  52. }
  53. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  54. return 6;
  55. }
  56. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  57. {
  58. return CGSizeMake((SCREEN_WIDTH - 63) * 0.5, 58.f);
  59. }
  60. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  61. {
  62. return 7.f;
  63. }
  64. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
  65. {
  66. return 9.f;
  67. }
  68. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  69. TDGroupLabelCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TDGroupLabelCell" forIndexPath:indexPath];
  70. cell.titleL.text = @"语文作文";
  71. cell.deleteBtn.hidden = NO;
  72. [cell.deleteBtn setAction:^{
  73. NSLog(@"deleteBtn");
  74. }];
  75. return cell;
  76. }
  77. @end