Commit 0a4657fc6bea6e1a482f0aebbc7015696e7e329c
1 parent
04531cda
no message
Showing
6 changed files
with
81 additions
and
31 deletions
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeCell.h
| @@ -9,7 +9,8 @@ | @@ -9,7 +9,8 @@ | ||
| 9 | #import <UIKit/UIKit.h> | 9 | #import <UIKit/UIKit.h> |
| 10 | 10 | ||
| 11 | NS_ASSUME_NONNULL_BEGIN | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | -#define kCNLiveNotSeeCell @"CNLiveNotSeeCell" | 12 | +static NSString * const kCNLiveNotSeeCell = @"CNLiveNotSeeCell"; |
| 13 | + | ||
| 13 | @class CNLiveNotSeeModel; | 14 | @class CNLiveNotSeeModel; |
| 14 | @class CNLiveNotSeeCell; | 15 | @class CNLiveNotSeeCell; |
| 15 | 16 |
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeCell.m
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeController.m
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | #import "CNLiveNavigationBar.h" | 20 | #import "CNLiveNavigationBar.h" |
| 21 | #import "CNLiveNotSeeCell.h" | 21 | #import "CNLiveNotSeeCell.h" |
| 22 | #import "CNLiveNotSeeModel.h" | 22 | #import "CNLiveNotSeeModel.h" |
| 23 | - | 23 | +#import "CNLiveNotSeeFooterView.h" |
| 24 | 24 | ||
| 25 | @interface CNLiveNotSeeController ()<UICollectionViewDelegate, UICollectionViewDataSource, CNLiveNotSeeCellDelegate>{ | 25 | @interface CNLiveNotSeeController ()<UICollectionViewDelegate, UICollectionViewDataSource, CNLiveNotSeeCellDelegate>{ |
| 26 | BOOL _isEdit; | 26 | BOOL _isEdit; |
| @@ -151,27 +151,9 @@ static const NSInteger SectionHeight = 50; | @@ -151,27 +151,9 @@ static const NSInteger SectionHeight = 50; | ||
| 151 | } | 151 | } |
| 152 | //组头/组尾 | 152 | //组头/组尾 |
| 153 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { | 153 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { |
| 154 | - | ||
| 155 | - // 如果当前想要的是头部视图 | ||
| 156 | - // UICollectionElementKindSectionHeader是一个const修饰的字符串常量,所以可以直接使用==比较 | ||
| 157 | - if (kind == UICollectionElementKindSectionHeader) { | ||
| 158 | - UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionElementKindSectionHeader" forIndexPath:indexPath]; | ||
| 159 | - headerView.backgroundColor = [UIColor clearColor]; | ||
| 160 | - return headerView; | ||
| 161 | - } | ||
| 162 | - else { // 返回每一组的尾部视图 | ||
| 163 | - UICollectionReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionElementKindSectionFooter" forIndexPath:indexPath]; | ||
| 164 | - footerView.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]; | ||
| 165 | - UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, SectionHeight)]; | ||
| 166 | - text.text = _type == CNTypeNoLetHimSee?@"把通讯录的某个朋友放到这里,生活圈可见范围发照片他(她)将无法看到。":@"把通讯录的某个朋友放到这里,该朋友更新的照片将不会在你的生活圈中出现。"; | ||
| 167 | - | ||
| 168 | - text.font = UIFontMake(12.0); | ||
| 169 | - text.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]; | ||
| 170 | - text.lineBreakMode = NSLineBreakByCharWrapping; | ||
| 171 | - text.numberOfLines = 0; | ||
| 172 | - [footerView addSubview:text]; | ||
| 173 | - return footerView; | ||
| 174 | - } | 154 | + CNLiveNotSeeFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:kCNLiveNotSeeFooterView forIndexPath:indexPath]; |
| 155 | + footerView.title = _type == CNTypeNoLetHimSee?@"把通讯录的某个朋友放到这里,生活圈可见范围发照片他(她)将无法看到。":@"把通讯录的某个朋友放到这里,该朋友更新的照片将不会在你的生活圈中出现。"; | ||
| 156 | + return footerView; | ||
| 175 | 157 | ||
| 176 | } | 158 | } |
| 177 | 159 | ||
| @@ -215,10 +197,9 @@ static const NSInteger SectionHeight = 50; | @@ -215,10 +197,9 @@ static const NSInteger SectionHeight = 50; | ||
| 215 | // 删除减号按钮 | 197 | // 删除减号按钮 |
| 216 | [self.afterData removeObject:self.minusModel]; | 198 | [self.afterData removeObject:self.minusModel]; |
| 217 | [self.beforeData removeObject:self.minusModel]; | 199 | [self.beforeData removeObject:self.minusModel]; |
| 218 | - | ||
| 219 | } | 200 | } |
| 220 | 201 | ||
| 221 | - self.title = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name; | 202 | + self.navigationBar.title.text = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name; |
| 222 | //判断完成按钮是否可以点击 | 203 | //判断完成按钮是否可以点击 |
| 223 | _navigationBar.right.userInteractionEnabled = ![self array:self.beforeData isEqualTo:self.afterData]; | 204 | _navigationBar.right.userInteractionEnabled = ![self array:self.beforeData isEqualTo:self.afterData]; |
| 224 | _navigationBar.right.selected = _navigationBar.right.userInteractionEnabled; | 205 | _navigationBar.right.selected = _navigationBar.right.userInteractionEnabled; |
| @@ -485,7 +466,9 @@ static const NSInteger SectionHeight = 50; | @@ -485,7 +466,9 @@ static const NSInteger SectionHeight = 50; | ||
| 485 | if(!_collectionView){ | 466 | if(!_collectionView){ |
| 486 | UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; | 467 | UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; |
| 487 | [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical]; | 468 | [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical]; |
| 488 | - | 469 | + flowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 0.0000001); |
| 470 | + flowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, SectionHeight); | ||
| 471 | + | ||
| 489 | //设置CollectionView的属性 | 472 | //设置CollectionView的属性 |
| 490 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; | 473 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; |
| 491 | _collectionView.scrollEnabled = NO; | 474 | _collectionView.scrollEnabled = NO; |
| @@ -497,11 +480,8 @@ static const NSInteger SectionHeight = 50; | @@ -497,11 +480,8 @@ static const NSInteger SectionHeight = 50; | ||
| 497 | _collectionView.showsVerticalScrollIndicator = NO; | 480 | _collectionView.showsVerticalScrollIndicator = NO; |
| 498 | _collectionView.showsHorizontalScrollIndicator = NO; | 481 | _collectionView.showsHorizontalScrollIndicator = NO; |
| 499 | [_collectionView registerClass:[CNLiveNotSeeCell class] forCellWithReuseIdentifier:kCNLiveNotSeeCell]; | 482 | [_collectionView registerClass:[CNLiveNotSeeCell class] forCellWithReuseIdentifier:kCNLiveNotSeeCell]; |
| 500 | - [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionElementKindSectionHeader"]; | ||
| 501 | - flowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 0.0000001); | ||
| 502 | 483 | ||
| 503 | - [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionElementKindSectionFooter"]; | ||
| 504 | - flowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT); | 484 | + [_collectionView registerClass:[CNLiveNotSeeFooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:kCNLiveNotSeeFooterView]; |
| 505 | } | 485 | } |
| 506 | return _collectionView; | 486 | return _collectionView; |
| 507 | } | 487 | } |
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeFooterView.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveNotSeeFooterView.h | ||
| 3 | +// CNLiveSettingModule_Example | ||
| 4 | +// | ||
| 5 | +// Created by CNLive-zxw on 2019/12/18. | ||
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <UIKit/UIKit.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | +static NSString * const kCNLiveNotSeeFooterView = @"CNLiveNotSeeFooterView"; | ||
| 13 | + | ||
| 14 | +@interface CNLiveNotSeeFooterView : UICollectionReusableView | ||
| 15 | +@property (nonatomic, copy) NSString *title; | ||
| 16 | + | ||
| 17 | +@end | ||
| 18 | + | ||
| 19 | +NS_ASSUME_NONNULL_END |
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeFooterView.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveNotSeeFooterView.m | ||
| 3 | +// CNLiveSettingModule_Example | ||
| 4 | +// | ||
| 5 | +// Created by CNLive-zxw on 2019/12/18. | ||
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveNotSeeFooterView.h" | ||
| 10 | +#import "QMUIKit.h" | ||
| 11 | +#import "CNLiveCategory.h" | ||
| 12 | + | ||
| 13 | +@interface CNLiveNotSeeFooterView() | ||
| 14 | +@property (nonatomic, strong) UILabel *titleLabel; | ||
| 15 | + | ||
| 16 | +@end | ||
| 17 | +@implementation CNLiveNotSeeFooterView | ||
| 18 | + | ||
| 19 | +- (instancetype)initWithFrame:(CGRect)frame{ | ||
| 20 | + self = [super initWithFrame:frame]; | ||
| 21 | + if (self) { | ||
| 22 | + self.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]; | ||
| 23 | + [self configSubviews]; | ||
| 24 | + } | ||
| 25 | + return self; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +- (void)configSubviews { | ||
| 29 | + [self addSubview:self.titleLabel]; | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +- (void)setTitle:(NSString *)title{ | ||
| 33 | + _title = title; | ||
| 34 | + _titleLabel.text = title; | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +- (UILabel *)titleLabel { | ||
| 38 | + if (!_titleLabel) { | ||
| 39 | + _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, 50)]; | ||
| 40 | + _titleLabel.font = UIFontMake(12.0); | ||
| 41 | + _titleLabel.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]; | ||
| 42 | + _titleLabel.lineBreakMode = NSLineBreakByCharWrapping; | ||
| 43 | + _titleLabel.numberOfLines = 0; | ||
| 44 | + } | ||
| 45 | + return _titleLabel; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +@end |
CNLiveSettingModule/Classes/Privacy/CNLivePrivacyCell.h
| @@ -9,7 +9,8 @@ | @@ -9,7 +9,8 @@ | ||
| 9 | #import <UIKit/UIKit.h> | 9 | #import <UIKit/UIKit.h> |
| 10 | 10 | ||
| 11 | NS_ASSUME_NONNULL_BEGIN | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | -#define kCNLivePrivacyCell @"CNLivePrivacyCell" | 12 | +static NSString * const kCNLivePrivacyCell = @"CNLivePrivacyCell"; |
| 13 | + | ||
| 13 | @class CNLivePrivacyModel; | 14 | @class CNLivePrivacyModel; |
| 14 | 15 | ||
| 15 | @interface CNLivePrivacyCell : UITableViewCell | 16 | @interface CNLivePrivacyCell : UITableViewCell |