123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- //
- // NoticeNewGroupMenuVC.m
- // smartRhino
- //
- // Created by armin on 2019/11/5.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "NoticeNewGroupMenuVC.h"
- #import "GHRefreshCollectionView.h"
- #import "NoticeNewGroupMenuCell.h"
- #import "ZLCollectionViewFlowLayout.h"
- @interface NoticeNewGroupMenuVC ()<UICollectionViewDelegate,UICollectionViewDataSource,ZLCollectionViewFlowLayoutDelegate>
- @property (strong,nonatomic) IBOutlet UIView *menuBgView;
- @property (strong,nonatomic) IBOutlet UIView *wenziBgView;
-
- @property (strong,nonatomic) GHRefreshCollectionView *menuCollectionView;
- @property (nonatomic,strong) ZLCollectionViewFlowLayout *flowLayout;
- @property (strong,nonatomic) NSMutableArray *menuDataSource;
- @end
- @implementation NoticeNewGroupMenuVC
- +(NoticeNewGroupMenuVC *)initNoticeNewGroupMenuVC{
- NoticeNewGroupMenuVC *controller = [StoryboardManager.shared.chatMsgNotice instantiateViewControllerWithIdentifier:@"NoticeNewGroupMenuVC"];
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
-
- self.menuCollectionView = [[GHRefreshCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowLayout];
- [self.menuBgView addSubview:self.menuCollectionView];
- WS(weakSelf);
- [self.menuCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.menuBgView).offset(30);
- make.right.equalTo(weakSelf.menuBgView).offset(-30);
- make.bottom.top.equalTo(@(0));
- }];
- [self.menuCollectionView registerNib:[UINib nibWithNibName:@"NoticeNewGroupMenuCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeNewGroupMenuCell"];
- self.menuCollectionView.backgroundColor = RGB(244, 244, 246);
- self.menuCollectionView.showsVerticalScrollIndicator = NO;
- self.menuCollectionView.showsHorizontalScrollIndicator = NO;
- self.menuCollectionView.alwaysBounceVertical = YES;
- [self.menuCollectionView setDataSource:self];
- [self.menuCollectionView setDelegate:self];
- [self.menuCollectionView reloadData];
- }
- -(void)changShow:(NoticeNewGroupMenuPageType )pageType{
- self.pageType = pageType;
- if(self.pageType == NoticeNewGroupMenuPageType_Menu){
- self.menuBgView.hidden = NO;
- self.wenziBgView.hidden = YES;
- [self.menuDataSource removeAllObjects];
- for (int i=0; i<4; i++) {
- NoticeNewGroupMenuModel *model = [[NoticeNewGroupMenuModel alloc] init];
- switch (i) {
- case 0:{
- model.menuImgName = @"chatmsg_notice_photo_icon";
- model.menuTitle = @"图片";
- }break;
- case 1:{
- model.menuImgName = @"chatmsg_notice_xiangji_icon";
- model.menuTitle = @"拍摄";
- }break;
- case 2:{
- model.menuImgName = @"chatmsg_notice_biji_icon";
- model.menuTitle = @"我的笔记";
- }break;
- case 3:{
- model.menuImgName = @"chatmsg_notice_sc_icon";
- model.menuTitle = @"我的收藏";
- }break;
- default:
- break;
- }
- [self.menuDataSource addObject:model];
- }
- [self.menuCollectionView reloadData];
- }else{
- self.menuBgView.hidden = YES;
- self.wenziBgView.hidden = NO;
- [self addWenziContent];
- }
- }
- /**********************************************************************/
- #pragma mark -ZLLayoutType的代理
- /**********************************************************************/
- - (ZLLayoutType)collectionView:(GHRefreshCollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section {
- return ClosedLayout;
- }
- /**********************************************************************/
- #pragma mark -如果是ClosedLayout样式的section,必须实现该代理,指定列数
- /**********************************************************************/
- - (NSInteger)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout columnCountOfSection:(NSInteger)section {
- return 4;
- }
- /**********************************************************************/
- #pragma mark -如果是百分比布局必须实现该代理,设置每个item的百分比,如果没实现默认比例为1
- /**********************************************************************/
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath {
- return 1;
- }
- #pragma mark UICollectionView
- - (NSInteger)numberOfSectionsInCollectionView:(GHRefreshCollectionView *)collectionView{
- if(collectionView == self.menuCollectionView){
- return 1;
- }
- return 0;
- }
- /**********************************************************************/
- #pragma mark -UICollectionViewDataSource
- /**********************************************************************/
- - (NSInteger)collectionView:(GHRefreshCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.menuDataSource.count;
- }
- - (UICollectionViewCell *)collectionView:(GHRefreshCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- NoticeNewGroupMenuModel *bean = [self.menuDataSource objectAtIndex:indexPath.item];
- NoticeNewGroupMenuCell *cell = [ collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeNewGroupMenuCell" forIndexPath:indexPath];
- cell.cell0ImgView.image = [UIImage imageNamed:bean.menuImgName];
- cell.cell0TitleLabel.text = bean.menuTitle;
-
- cell.backgroundColor = RGB(244, 244, 246);
- cell.contentView.backgroundColor = RGB(244, 244, 246);
- return cell;
- }
- /****************************************************/
- #pragma mark --UICollectionViewDelegateFlowLayout
- /****************************************************/
- - (CGSize)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- CGFloat width = SCREEN_WIDTH / 4;
- CGFloat height = 112;
- return CGSizeMake(width, height);
- }
- -(UIEdgeInsets)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
- {
- return UIEdgeInsetsMake(0,0,0,0);
- }
-
- - (void)collectionView:(GHRefreshCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- [collectionView deselectItemAtIndexPath:indexPath animated:YES];
- NoticeNewGroupMenuModel *bean = [self.menuDataSource objectAtIndex:indexPath.item];
- NSLog(@"%@",bean.menuTitle);
- if(self.isAutomaticHidePage){
- self.view.hidden = !self.view.hidden;
- }
- if(self.delegate && [self.delegate respondsToSelector:@selector(userDidSelectMenuWithIndex:title:)]){
- [self.delegate userDidSelectMenuWithIndex:indexPath.item title:bean.menuTitle];
- }
- }
- -(NSMutableArray *)menuDataSource{
- if(!_menuDataSource){
- _menuDataSource = [[NSMutableArray alloc] init];
- }
- return _menuDataSource;
- }
-
- -(void)addWenziContent{
- [self.wenziBgView removeAllSubviews];
-
- UILabel *ziHao = [[UILabel alloc] init];
- [self.wenziBgView addSubview:ziHao];
- ziHao.text = @"字号";
- ziHao.textColor = RGB(10, 10, 10);
- ziHao.font = [UIFont systemFontOfSize:12];
- ziHao.frame = CGRectMake(15, self.wenziBgView.height - 110, 30, 30);
- [ziHao sizeToFit];
-
- UILabel *ziHaoRight = [[UILabel alloc] init];
- [self.wenziBgView addSubview:ziHaoRight];
- ziHaoRight.text = @"较小";
- ziHaoRight.textColor = RGB(10, 10, 10);
- ziHaoRight.font = [UIFont systemFontOfSize:12];
- ziHaoRight.frame = CGRectMake(SCREEN_WIDTH - 70, self.wenziBgView.height - 110, 30, 30);
- [ziHaoRight sizeToFit];
-
- NSMutableArray *allYuanViewArr = [[NSMutableArray alloc] init];
-
- CGFloat yuanWidth = 16;
- CGFloat startX = 60;
- CGFloat endX = SCREEN_WIDTH - 80;
- CGFloat txLineWidth = (endX - startX - 4*yuanWidth) / 3;
- CGFloat startY = ziHao.y;
- for(int i=0;i<4;i++){
- UIView *yuanContentView = [[UIView alloc] init];
- [self.wenziBgView addSubview:yuanContentView];
- yuanContentView.frame = CGRectMake(startX+i*txLineWidth + i*yuanWidth, startY, yuanWidth, yuanWidth);
- yuanContentView.backgroundColor = [UIColor whiteColor];
- [yuanContentView setRadius:yuanWidth/2.0 borderColor:RGB(162, 162, 162) borderWidth:.5];
-
- if(i < 3){
- UIView *yuanMianLineContentView = [[UIView alloc] init];
- [self.wenziBgView addSubview:yuanMianLineContentView];
- yuanMianLineContentView.frame = CGRectMake(yuanContentView.x + yuanContentView.width - 1, startY + yuanWidth/4, txLineWidth + 2, yuanWidth - yuanWidth/2);
- yuanMianLineContentView.backgroundColor = [UIColor whiteColor];
- [yuanMianLineContentView setRadius:0 borderColor:RGB(162, 162, 162) borderWidth:.5];
- }
- [allYuanViewArr addObject:yuanContentView];
-
- UILabel *TLabel = [[UILabel alloc] init];
- [self.wenziBgView addSubview:TLabel];
- TLabel.text = @"T";
- TLabel.textColor = RGB(10, 10, 10);
- TLabel.font = [UIFont systemFontOfSize:12 + i*2];
- TLabel.frame = CGRectMake(yuanContentView.x + 2, self.wenziBgView.height - 145, 30, 30);
- [TLabel sizeToFit];
-
- if(i == 0){
- UIView *heiView = [[UIView alloc] init];
- [yuanContentView addSubview:heiView];
- heiView.backgroundColor = [UIColor blackColor];
- heiView.frame = CGRectMake(yuanContentView.width/4, yuanContentView.width/4, yuanContentView.width/2, yuanContentView.width/2);
- [heiView setRadius:yuanContentView.width/4 corners:UIRectCornerAllCorners];
- }
-
- }
-
- for (UIView *yuanView in allYuanViewArr) {
- [self.wenziBgView bringSubviewToFront:yuanView];
- }
-
-
-
-
- UILabel *ziColor = [[UILabel alloc] init];
- [self.wenziBgView addSubview:ziColor];
- ziColor.text = @"字色";
- ziColor.textColor = RGB(10, 10, 10);
- ziColor.font = [UIFont systemFontOfSize:12];
- ziColor.frame = CGRectMake(15, self.wenziBgView.height - 50, 30, 30);
- [ziColor sizeToFit];
-
- [self.wenziBgView sizeToFit];
-
- UIScrollView *scrollView = [[UIScrollView alloc] init];
- [self.wenziBgView addSubview:scrollView];
- scrollView.frame = CGRectMake(50, ziColor.y - 10, SCREEN_WIDTH - 50, 40);
- [scrollView sizeToFit];
-
- CGFloat jg = 12;
- CGFloat x = 0;
- CGFloat y = 0;
- CGFloat wh = 30;
- for(int i=0;i<7;i++){
- UIView *colorBgView = [[UIView alloc] init];
- [scrollView addSubview:colorBgView];
- colorBgView.frame = CGRectMake(x + i*jg, y, wh, wh);
- [colorBgView setRadius:2 corners:UIRectCornerAllCorners];
- x += wh;
-
- switch (i) {
- case 0:{
- colorBgView.backgroundColor = RGB(74, 74, 74);
- }break;
- case 1:{
- colorBgView.backgroundColor = RGB(155, 155, 155);
- }break;
- case 2:{
- colorBgView.backgroundColor = RGB(204, 204, 204);
- }break;
- case 3:{
- colorBgView.backgroundColor = RGB(229, 111, 111);
- }break;
- case 4:{
- colorBgView.backgroundColor = RGB(100, 156, 224);
- }break;
- case 5:{
- colorBgView.backgroundColor = RGB(237, 178, 79);
- }break;
- case 6:{
- colorBgView.backgroundColor = RGB(132, 73, 221);
- }break;
- default:{
- colorBgView.backgroundColor = RGB(132, 73, 221);
- }break;
- }
- if(colorBgView.x + wh <= SCREEN_WIDTH - 50){
- scrollView.contentSize = CGSizeMake(SCREEN_WIDTH - 49 , 40);
- }else{
- scrollView.contentSize = CGSizeMake(colorBgView.x + wh, 40);
- }
- }
-
- scrollView.showsHorizontalScrollIndicator = NO;//不显示水平拖地的条
- scrollView.showsVerticalScrollIndicator=NO;//不显示垂直拖动的条
-
- self.automaticallyAdjustsScrollViewInsets = NO;
- self.edgesForExtendedLayout = UIRectEdgeNone;
- }
- - (ZLCollectionViewFlowLayout *)flowLayout{
- if(_flowLayout == nil){
- _flowLayout = [[ZLCollectionViewFlowLayout alloc] init];
- _flowLayout.delegate = self;
- }
- return _flowLayout;
- }
- @end
|