Commit c285d9ac authored by admin's avatar admin

完成排序 筛选下拉菜单

parent 4776d0ee
This diff is collapsed.
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define kLoginButtonBackGroundColor [UIColor colorWithRed:0 / 255.0 green:111 / 255.0 blue:188 / 255.0 alpha:1.0] #define kLoginButtonBackGroundColor [UIColor colorWithRed:0 / 255.0 green:111 / 255.0 blue:188 / 255.0 alpha:1.0]
// #dddddd // #dddddd
#define kSeparateLineColor [UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:1.0] #define kSeparateLineColor [UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:1.0]
#define kSeparateLineCGColor [[UIColor colorWithRed:221 / 255.0 green:221 / 255.0 blue:221 / 255.0 alpha:1.0] CGColor]
// ----- Home ----- // ----- Home -----
// #bbbbbb // #bbbbbb
...@@ -126,6 +127,8 @@ ...@@ -126,6 +127,8 @@
#define kCommentViewHeight 335 #define kCommentViewHeight 335
#define kTaxisViewHeight 150 #define kTaxisViewHeight 150
#define kScreenViewHeight 240
#import "UIView+Extension.h" #import "UIView+Extension.h"
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define kQuestionListCell @"questionListTableViewCell" #define kQuestionListCell @"questionListTableViewCell"
@interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource> @interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, ScreenTableDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *allQuestionArray; @property (nonatomic, strong) NSMutableArray *allQuestionArray;
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
@property (nonatomic, strong) MenuView *menuView; @property (nonatomic, strong) MenuView *menuView;
@property (nonatomic, strong) TaxisView *taxisView; @property (nonatomic, strong) TaxisView *taxisView;
@property (nonatomic, strong) UIView *taxisBackGroundView; @property (nonatomic, strong) ScreenView *screenView;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) MenuButton *selctedButton;
@property (nonatomic, strong) ScreenView *screenView;
@property (nonatomic, strong) UIView *screenBackGroundView;
@end @end
@implementation QuestionViewController @implementation QuestionViewController
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) { [httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
NSDictionary *dataDict = (NSDictionary *)response[@"data"]; NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"]; NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"recods = %@", recordsDict); NSLog(@"问题与知识列表recods = %@", recordsDict);
for (NSDictionary *questionDict in recordsDict) { for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init]; QuestionModel *question = [[QuestionModel alloc] init];
[question setValuesForKeysWithDictionary:questionDict]; [question setValuesForKeysWithDictionary:questionDict];
...@@ -146,118 +146,176 @@ ...@@ -146,118 +146,176 @@
[self.navigationController pushViewController:addQuestionVC animated:YES]; [self.navigationController pushViewController:addQuestionVC animated:YES];
} }
- (void)dropCilck:(UIButton *)sender - (void)dropCilck:(MenuButton *)sender
{ {
sender.selected = !sender.selected; sender.isDrop = !sender.isDrop;
[self closeScreenBackGroundView];
[self closeTaxisBackGroundView]; if (_selctedButton.tag == sender.tag) {
if (sender.tag == 4001) {
if (sender.selected) { if (sender.isDrop) {
[self showTaxisBackGroundView]; if (sender.tag == 4001) {
[self showRedView];
} else {
[self showGreenView];
}
[sender setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
} else { } else {
[self closeTaxisBackGroundView]; if (sender.tag == 4001) {
[self closeRedView];
} else {
[self closeGreenView];
}
[sender setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
} }
} else { } else {
if (sender.selected) { // 前一次选中的按钮 选中状态置为NO
[self showScreenBackGroundView]; _selctedButton.selected = NO;
_selctedButton.isDrop = NO;
// 进行选中状态为NO 的操作
// 1.将发生“选中”->“未选中”状态变化的按钮文字由Orange->White
[_selctedButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
// 2.判断当前是否有bgView 有->移除, 没有->跳过
if (_bgView) {
// _bgView存在
[_bgView removeFromSuperview];
_bgView = nil;
}
if (_taxisView) {
[_taxisView removeFromSuperview];
_taxisView = nil;
}
if (_screenView) {
[_screenView removeFromSuperview];
_screenView = nil;
}
// 将当前选中的按钮设置 选中状态为YES;
sender.selected = YES;
// 对选中按钮 进行相关操作
// 1.将选中按钮的文字设置为Orange
[sender setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_selctedButton = (MenuButton *)sender;
if (sender.tag == 4001) {
[self showRedView];
} else { } else {
[self closeScreenBackGroundView]; [self showGreenView];
} }
} }
} }
- (void)showTaxisBackGroundView
- (void)showRedView
{ {
if (!_taxisBackGroundView) { if (!_bgView) {
_taxisBackGroundView = [[UIView alloc] initWithFrame:self.view.bounds]; _bgView = [[UIView alloc] initWithFrame:self.view.bounds];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeTaxisBackGroundView)]; UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeRedView)];
[_taxisBackGroundView addGestureRecognizer:tapGR]; [_bgView addGestureRecognizer:tapGR];
} }
if (!_taxisView) { if (!_taxisView) {
_taxisView = [[TaxisView alloc] init]; _taxisView = [[TaxisView alloc] init];
_taxisView.backgroundColor = [UIColor whiteColor]; _taxisView.backgroundColor = [UIColor whiteColor];
} }
[self.view insertSubview:_taxisBackGroundView atIndex:555];
[self.view insertSubview:_taxisView aboveSubview:_taxisBackGroundView];
_taxisBackGroundView.alpha = 0; [self.view addSubview:_bgView];
_taxisBackGroundView.backgroundColor = [UIColor blackColor]; [self.view insertSubview:_taxisView aboveSubview:_bgView];
_bgView.alpha = 0;
_bgView.backgroundColor = [UIColor blackColor];
CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kTaxisViewHeight); CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kTaxisViewHeight);
CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight); CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight);
_taxisView.frame = fromFrame; _taxisView.frame = fromFrame;
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
_taxisBackGroundView.alpha = 0.6; _bgView.alpha = 0.6;
_taxisView.frame = toFrame; _taxisView.frame = toFrame;
}]; }];
}
- (void)closeRedView
{
_selctedButton.isDrop = NO;
[_selctedButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight);
[UIView animateWithDuration:0.3 animations:^{
_bgView.alpha = .0f;
_taxisView.frame = fromFrame;
} completion:^(BOOL finished) {
[_bgView removeFromSuperview];
[_taxisView removeFromSuperview];
}];
} }
- (void)showScreenBackGroundView
- (void)showGreenView
{ {
if (!_screenBackGroundView) { if (!_bgView) {
_screenBackGroundView = [[UIView alloc] initWithFrame:self.view.bounds]; _bgView = [[UIView alloc] initWithFrame:self.view.bounds];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeScreenBackGroundView)]; UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeGreenView)];
[_screenBackGroundView addGestureRecognizer:tapGR]; [_bgView addGestureRecognizer:tapGR];
} }
if (!_screenView) { if (!_screenView) {
_screenView = [[ScreenView alloc] init]; _screenView = [[ScreenView alloc] init];
_screenView.delegate = self;
_screenView.backgroundColor = [UIColor whiteColor]; _screenView.backgroundColor = [UIColor whiteColor];
} }
[self.view insertSubview:_screenBackGroundView atIndex:555];
[self.view insertSubview:_screenView aboveSubview:_screenBackGroundView];
_screenBackGroundView.alpha = 0; [self.view addSubview:_bgView];
_screenBackGroundView.backgroundColor = [UIColor blackColor]; [self.view insertSubview:_screenView aboveSubview:_bgView];
CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kTaxisViewHeight); _bgView.alpha = 0;
CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight); _bgView.backgroundColor = [UIColor blackColor];
CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kScreenViewHeight);
CGRect fromFrame = CGRectMake(0, -kScreenViewHeight, kScreenWidth, kScreenViewHeight);
_screenView.frame = fromFrame; _screenView.frame = fromFrame;
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
_screenBackGroundView.alpha = 0.6; _bgView.alpha = 0.6;
_screenView.frame = toFrame; _screenView.frame = toFrame;
}]; }];
} }
- (void)closeGreenView
- (void)closeTaxisBackGroundView
{ {
if (_taxisBackGroundView) { _selctedButton.isDrop = NO;
CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight); [_selctedButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
[UIView animateWithDuration:0.3 animations:^{ CGRect fromFrame = CGRectMake(0, -kScreenViewHeight, kScreenWidth, kScreenViewHeight);
_taxisBackGroundView.alpha = .0f; [UIView animateWithDuration:0.3 animations:^{
_taxisView.frame = fromFrame; _bgView.alpha = .0f;
} completion:^(BOOL finished) { _screenView.frame = fromFrame;
[_taxisBackGroundView removeFromSuperview]; } completion:^(BOOL finished) {
[_taxisView removeFromSuperview]; [_bgView removeFromSuperview];
}]; [_screenView removeFromSuperview];
} }];
} }
- (void)closeScreenBackGroundView
{
if (_screenBackGroundView) {
CGRect fromFrame = CGRectMake(0, -kTaxisViewHeight, kScreenWidth, kTaxisViewHeight);
[UIView animateWithDuration:0.3 animations:^{
_screenBackGroundView.alpha = .0f;
_screenView.frame = fromFrame;
} completion:^(BOOL finished) {
[_screenBackGroundView removeFromSuperview];
[_screenView removeFromSuperview];
}];
}
}
- (void)searchBarClick:(UIButton *)sender - (void)searchBarClick:(UIButton *)sender
{ {
NSLog(@"%@", self.searchBar.searchTextFiled.text); NSLog(@"%@", self.searchBar.searchTextFiled.text);
} }
#pragma mark - ScreenTableDelegate
- (void)click
{
NSLog(@"点一下");
[self closeGreenView];
}
#pragma mark - UItableView Delegate/DataSource #pragma mark - UItableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getPraiseDetailWithParameters:nil completion:^(id response, NSError *error) { [httpClient getPraiseDetailWithParameters:nil completion:^(id response, NSError *error) {
NSLog(@"PraiseDetail = %@", response); NSLog(@"口碑巡检明细PraiseDetail = %@", response);
}]; }];
// NSDictionary *paramr = @{@"uuid":@"5a74170150dba4ed0150dbad2e4d0001", // NSDictionary *paramr = @{@"uuid":@"5a74170150dba4ed0150dbad2e4d0001",
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
@"pageSize":@(10) @"pageSize":@(10)
}; };
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"respone = %@", response); NSLog(@"巡检列表respone = %@", response);
}]; }];
} }
......
...@@ -10,8 +10,13 @@ ...@@ -10,8 +10,13 @@
@interface RankDetailTableCell : UITableViewCell @interface RankDetailTableCell : UITableViewCell
@property (nonatomic, assign) BOOL isDrop; // 判断是否drop
@property (nonatomic, strong) UIImageView *arrowImageView; @property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UIButton *mainTitleBtn; @property (nonatomic, strong) UIButton *mainTitleBtn;
@property (nonatomic, strong) UILabel *scoreLabel; @property (nonatomic, strong) UILabel *scoreLabel;
@property (nonatomic, strong) UIScrollView *scrollView;
@end @end
...@@ -22,9 +22,8 @@ ...@@ -22,9 +22,8 @@
@property (nonatomic, strong) NSArray *workData; @property (nonatomic, strong) NSArray *workData;
@property (nonatomic, strong) NSArray *test1Array; @property (nonatomic, strong) NSMutableDictionary *selectedIndexes; // 存放二次展开的cell
@property (nonatomic, strong) NSArray *test2Array;
@property (nonatomic, strong) NSArray *test3Array;
@end @end
...@@ -45,9 +44,8 @@ ...@@ -45,9 +44,8 @@
// 添加tableView // 添加tableView
[self addTableView]; [self addTableView];
self.test1Array = [NSArray arrayWithObjects:@"全员服务",@"15分钟退单",@"送货跟单",@"企划环境升级",@"物业环境改造", nil]; // 初始化容器
self.test2Array = [NSArray arrayWithObjects:@(100),@(100),@(99),@(100),@(98), nil]; self.selectedIndexes = [[NSMutableDictionary alloc] init];
self.test3Array = [NSArray arrayWithObjects:@(1),@(1),@(2),@(1),@(3), nil];
} }
...@@ -75,6 +73,65 @@ ...@@ -75,6 +73,65 @@
[self.tableView registerClass:[RankDetailTableCell class] forCellReuseIdentifier:kRankDetailCell]; [self.tableView registerClass:[RankDetailTableCell class] forCellReuseIdentifier:kRankDetailCell];
} }
- (void)showScrollView:(UIButton *)sender
{
RankDetailTableCell * cell = (RankDetailTableCell *)[[sender superview] superview];
cell.isDrop = !cell.isDrop;
NSIndexPath * path = [self.tableView indexPathForCell:cell];
[_tableView deselectRowAtIndexPath:path animated:TRUE];
BOOL isSelected = ![self cellIsSelected:path];
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[_selectedIndexes setObject:selectedIndex forKey:path];
if (cell.isDrop) {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}];
cell.scrollView = [[UIScrollView alloc] init];
cell.scrollView.backgroundColor = [UIColor lightGrayColor];
cell.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:cell.scrollView];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:cell.scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:45];
[cell.contentView addConstraint:someoneTop];
NSLayoutConstraint *someoneLeft = [NSLayoutConstraint constraintWithItem:cell.scrollView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[cell.contentView addConstraint:someoneLeft];
NSLayoutConstraint *someoneRight = [NSLayoutConstraint constraintWithItem:cell.scrollView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[cell.contentView addConstraint:someoneRight];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:cell.scrollView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
[cell.contentView addConstraint:someoneHeight];
} else {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(0);
}];
if (cell.scrollView) {
[cell.scrollView removeFromSuperview];
cell.scrollView = nil;
}
}
[_tableView beginUpdates];
[_tableView endUpdates];
}
- (BOOL)cellIsSelected:(NSIndexPath *)indexPath {
// Return whether the cell at the specified index path is selected or not
NSNumber *selectedIndex = [_selectedIndexes objectForKey:indexPath];
return selectedIndex == nil ? FALSE : [selectedIndex boolValue];
}
#pragma mark - UITableView DataSource/Delegate #pragma mark - UITableView DataSource/Delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
...@@ -99,9 +156,12 @@ ...@@ -99,9 +156,12 @@
WorkModel *workModel = _workData[indexPath.section]; WorkModel *workModel = _workData[indexPath.section];
NSDictionary *dict = workModel.Info[indexPath.row]; NSDictionary *dict = workModel.Info[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.mainTitleBtn setTitle:[NSString stringWithFormat:@"%d、%@", (int)(indexPath.row + 1),dict[@"titles"]] forState:UIControlStateNormal]; [cell.mainTitleBtn setTitle:[NSString stringWithFormat:@"%d、%@", (int)(indexPath.row + 1),dict[@"titles"]] forState:UIControlStateNormal];
cell.scoreLabel.text = [NSString stringWithFormat:@"%@分", dict[@"scroes"]]; cell.scoreLabel.text = [NSString stringWithFormat:@"%@分", dict[@"scroes"]];
// 按钮点击事件
[cell.mainTitleBtn addTarget:self action:@selector(showScrollView:) forControlEvents:UIControlEventTouchUpInside];
return cell; return cell;
...@@ -116,7 +176,11 @@ ...@@ -116,7 +176,11 @@
// cell的高度 // cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
return 45; if([self cellIsSelected:indexPath]) {
return 130;
}
return 44;
} }
// section高度 // section高度
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"response = %@", response); NSLog(@"口碑排名response = %@", response);
}]; }];
} }
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
HttpClient *httpClient = [[HttpClient alloc] initWithLogin]; HttpClient *httpClient = [[HttpClient alloc] initWithLogin];
[httpClient loginWithUsername:username password:password completion:^(id response, NSError *error) { [httpClient loginWithUsername:username password:password completion:^(id response, NSError *error) {
NSLog(@"登陆 respo = %@", response);
if ([response[@"message"] isEqualToString:@"ok"]) { if ([response[@"message"] isEqualToString:@"ok"]) {
// 保存登陆信息 // 保存登陆信息
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
......
...@@ -10,4 +10,6 @@ ...@@ -10,4 +10,6 @@
@interface MenuButton : UIButton @interface MenuButton : UIButton
@property (nonatomic, assign) BOOL isDrop;
@end @end
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
_taxiButton.tag = 4001; _taxiButton.tag = 4001;
_taxiButton.translatesAutoresizingMaskIntoConstraints = NO; _taxiButton.translatesAutoresizingMaskIntoConstraints = NO;
[_taxiButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; [_taxiButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
[_taxiButton setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
_taxiButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; _taxiButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
[_taxiButton setTitle:@"排序" forState:UIControlStateNormal]; [_taxiButton setTitle:@"排序" forState:UIControlStateNormal];
[self addSubview:_taxiButton]; [self addSubview:_taxiButton];
...@@ -78,7 +77,6 @@ ...@@ -78,7 +77,6 @@
_screenButton.translatesAutoresizingMaskIntoConstraints = NO; _screenButton.translatesAutoresizingMaskIntoConstraints = NO;
_screenButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; _screenButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
[_screenButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; [_screenButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
[_screenButton setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
[_screenButton setTitle:@"筛选" forState:UIControlStateNormal]; [_screenButton setTitle:@"筛选" forState:UIControlStateNormal];
[self addSubview:_screenButton]; [self addSubview:_screenButton];
......
//
// GroupItems.h
// 垂直TabBar
//
// Created by admin on 15/11/14.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface GroupItems : NSObject
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) UIView *view;
- (instancetype)initWithTitle:(NSString *)title view:(UIView *)view;
@end
//
// GroupItems.m
// 垂直TabBar
//
// Created by admin on 15/11/14.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "GroupItems.h"
@implementation GroupItems
- (instancetype)initWithTitle:(NSString *)title view:(UIView *)view
{
self = [super init];
if (self) {
self.view = view;
self.title = title;
}
return self;
}
@end
//
// GroupTabBar.h
// 垂直TabBar
//
// Created by admin on 15/11/14.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol GroupTabBarDelegate <NSObject>
// 选中view
- (void)switchView:(UIView *)view;
@end
@interface GroupTabBar : UIView
@property (nonatomic, strong) UIButton *stateBtn; // 状态
@property (nonatomic, strong) UIButton *titleBtn; // 标题
@property (nonatomic, strong) UIButton *sigleBtn; // 单号
@property (nonatomic,assign) id <GroupTabBarDelegate> delegate; // 设置代理
@property (nonatomic, strong) NSArray *items;
- (void)showIndex:(NSInteger)index;
@end
//
// GroupTabBar.m
// 垂直TabBar
//
// Created by admin on 15/11/14.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "GroupTabBar.h"
#import "GroupItems.h"
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kSelfWidth self.frame.size.width
#define kSelfHeight self.frame.size.height
@interface GroupTabBar ()
@property (strong) NSMutableArray *buttons; // 存放所有button的数组
@end
@implementation GroupTabBar
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.buttons = [NSMutableArray array];
}
return self;
}
- (void)setItems:(NSArray *)items
{
_items = items;
CGFloat buttonHeight = kSelfHeight / _items.count;
for (int i = 0; i < _items.count; i++) {
GroupItems *item = _items[i];
UIButton *button = [[UIButton alloc] init];
button.titleLabel.font = [UIFont systemFontOfSize:15.0];
[button setTitleColor:kLightBlack forState:UIControlStateNormal];
button.frame = CGRectMake(0, i * buttonHeight, kSelfWidth, buttonHeight);
[button setTitle:item.title forState:UIControlStateNormal];
[button addTarget:self action:@selector(touchDownForButton:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(touchUpForButton:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
[self.buttons addObject:button];
}
}
- (void)showIndex:(NSInteger) index
{
NSLog(@"self.buttons = %@", self.buttons);
[self touchDownForButton:[self.buttons objectAtIndex:index]];
[self touchUpForButton:[self.buttons objectAtIndex:index]];
}
- (void)touchDownForButton:(UIButton *)button{
button.selected = YES;
NSInteger i = [self.buttons indexOfObject:button];
UIView *view = [[self.items objectAtIndex:i] view];
if (_delegate) {
[_delegate switchView:view];
}
for (UIButton * b in self.buttons) {
b.selected = NO;
}
}
- (void)touchUpForButton:(UIButton *)button {
for (UIButton * b in self.buttons) {
b.selected = NO;
b.backgroundColor = kSectionBackGroundColor;
}
button.selected = YES;
button.backgroundColor = [UIColor whiteColor];
}
@end
...@@ -7,7 +7,26 @@ ...@@ -7,7 +7,26 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "GroupTabBar.h"
@protocol ScreenTableDelegate <NSObject>
- (void)click;
@end
@interface ScreenView : UIView @interface ScreenView : UIView
@property (nonatomic, strong) GroupTabBar *groupTabBar; // 重置
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UIView *cyanView;
@property (nonatomic, strong) UIButton *resetBtn; // 重置
@property (nonatomic, strong) UIButton *submitBtn; // 提交
@property (nonatomic, weak) id <ScreenTableDelegate> delegate;
@end @end
...@@ -7,6 +7,18 @@ ...@@ -7,6 +7,18 @@
// //
#import "ScreenView.h" #import "ScreenView.h"
#import "GroupItems.h"
#define SELECTED_VIEW_CONTROLLER_TAG 98456345
#define kScreenTabelViewCell @"screenTableViewCell"
@interface ScreenView () <GroupTabBarDelegate, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate>
@property (nonatomic, strong) UILabel *placeholderLabel1;
@property (nonatomic, strong) NSArray *testArray;
@property (nonatomic, strong) UIView *backView;
@end
@implementation ScreenView @implementation ScreenView
...@@ -30,7 +42,168 @@ ...@@ -30,7 +42,168 @@
- (void)setup - (void)setup
{ {
self.backgroundColor = [UIColor greenColor]; self.testArray = [NSArray arrayWithObjects:@"全部",@"未提交",@"已提交",@"调研中",@"已过期", @"未完成", nil];
self.groupTabBar = [[GroupTabBar alloc] initWithFrame:CGRectMake(0, 0, 100, 180)];
_groupTabBar.delegate = self;
[self addSubview:_groupTabBar];
self.tableView = [[UITableView alloc] init];
_tableView.delegate = self;
_tableView.dataSource = self;
GroupItems *tableItem = [[GroupItems alloc] initWithTitle:@"状态等于" view:_tableView];
self.textView = [[UITextView alloc] init];
_textView.delegate = self;
self.placeholderLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 100, 30)];
self.placeholderLabel1.text = @"请输入标题...";
self.placeholderLabel1.font = [UIFont systemFontOfSize:15.0];
self.placeholderLabel1.textColor = kOnLineCellDetailColor;
[self.textView addSubview:self.placeholderLabel1];
GroupItems *textItem = [[GroupItems alloc] initWithTitle:@"标题类似于" view:_textView];
self.cyanView = [[UIView alloc] init];
GroupItems *cyanItem = [[GroupItems alloc] initWithTitle:@"单号等于" view:_cyanView];
[self insertSubview:_tableView belowSubview:_groupTabBar];
[self insertSubview:_textView belowSubview:_groupTabBar];
[self insertSubview:_cyanView belowSubview:_groupTabBar];
_groupTabBar.items = @[tableItem, textItem, cyanItem];
[_groupTabBar showIndex:0];
self.backView.backgroundColor = [UIColor whiteColor];
[self.resetBtn setTitle:@"重置" forState:UIControlStateNormal];
[self.submitBtn setTitle:@"提交" forState:UIControlStateNormal];
}
#pragma mark - UITextView Delegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if (![text isEqualToString:@""]) {
_placeholderLabel1.hidden = YES;
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
_placeholderLabel1.hidden = NO;
}
return YES;
}
#pragma mark - UITabelViewDelgate / DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _testArray.count;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kScreenTabelViewCell];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kScreenTabelViewCell];
}
cell.textLabel.text = _testArray[indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell;
}
// cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_delegate) {
[_delegate click];
}
}
- (void)switchView:(UIView *)view
{
UIView *currentView = [self viewWithTag:SELECTED_VIEW_CONTROLLER_TAG];
[currentView removeFromSuperview];
currentView = nil;
view.frame = CGRectMake(self.groupTabBar.frame.size.width,0,kScreenWidth - self.groupTabBar.frame.size.width, self.groupTabBar.size.height);
view.tag = SELECTED_VIEW_CONTROLLER_TAG;
[self insertSubview:view belowSubview:_groupTabBar];
}
- (UIView *)backView
{
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_backView];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_backView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.groupTabBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:lineViewTop];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_backView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:lineViewRight];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_backView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:lineViewBottom];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_backView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:lineViewLeft];
}
return _backView;
}
- (UIButton *)resetBtn
{
if (!_resetBtn) {
_resetBtn = [[UIButton alloc] init];
_resetBtn.backgroundColor = [UIColor grayColor];
_resetBtn.translatesAutoresizingMaskIntoConstraints = NO;
[self.backView addSubview:_resetBtn];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.backView addConstraint:lineViewTop];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-20];
[self.backView addConstraint:lineViewRight];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
[self.backView addConstraint:lineViewBottom];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_resetBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.backView addConstraint:lineViewLeft];
}
return _resetBtn;
}
- (UIButton *)submitBtn
{
if (!_submitBtn) {
_submitBtn = [[UIButton alloc] init];
_submitBtn.backgroundColor = kNavigationBarColor;
_submitBtn.translatesAutoresizingMaskIntoConstraints = NO;
[self.backView addSubview:_submitBtn];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_submitBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.backView addConstraint:lineViewTop];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_submitBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.backView addConstraint:lineViewRight];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_submitBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
[self.backView addConstraint:lineViewBottom];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_submitBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.backView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:20];
[self.backView addConstraint:lineViewLeft];
}
return _submitBtn;
} }
/* /*
......
...@@ -31,12 +31,9 @@ ...@@ -31,12 +31,9 @@
- (void)setup - (void)setup
{ {
[self.defaultBtn setTitle:@"默认排序" forState:UIControlStateNormal]; [self.defaultBtn setTitle:@"默认排序" forState:UIControlStateNormal];
self.defaultBtn.backgroundColor = [UIColor orangeColor];
[self.sequenceBtn setTitle:@"时间顺序排序" forState:UIControlStateNormal]; [self.sequenceBtn setTitle:@"时间顺序排序" forState:UIControlStateNormal];
self.sequenceBtn.backgroundColor = [UIColor orangeColor];
[self.changeoverBtn setTitle:@"时间逆序排序" forState:UIControlStateNormal]; [self.changeoverBtn setTitle:@"时间逆序排序" forState:UIControlStateNormal];
self.changeoverBtn.backgroundColor = [UIColor orangeColor];
} }
...@@ -45,7 +42,13 @@ ...@@ -45,7 +42,13 @@
{ {
if (!_defaultBtn) { if (!_defaultBtn) {
_defaultBtn = [[UIButton alloc] init]; _defaultBtn = [[UIButton alloc] init];
_defaultBtn.layer.borderWidth = 0.5;
_defaultBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
_defaultBtn.layer.borderColor = kSeparateLineCGColor;
_defaultBtn.translatesAutoresizingMaskIntoConstraints = NO; _defaultBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_defaultBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
_defaultBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
_defaultBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
[self addSubview:_defaultBtn]; [self addSubview:_defaultBtn];
// 顶端 // 顶端
...@@ -71,7 +74,14 @@ ...@@ -71,7 +74,14 @@
{ {
if (!_sequenceBtn) { if (!_sequenceBtn) {
_sequenceBtn = [[UIButton alloc] init]; _sequenceBtn = [[UIButton alloc] init];
_sequenceBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
_sequenceBtn.translatesAutoresizingMaskIntoConstraints = NO; _sequenceBtn.translatesAutoresizingMaskIntoConstraints = NO;
_sequenceBtn.layer.borderColor = kSeparateLineCGColor;
_sequenceBtn.layer.borderWidth = 0.5;
[_sequenceBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
_sequenceBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
_sequenceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
[self addSubview:_sequenceBtn]; [self addSubview:_sequenceBtn];
// 顶端 // 顶端
...@@ -97,7 +107,13 @@ ...@@ -97,7 +107,13 @@
{ {
if (!_changeoverBtn) { if (!_changeoverBtn) {
_changeoverBtn = [[UIButton alloc] init]; _changeoverBtn = [[UIButton alloc] init];
_changeoverBtn.layer.borderColor = kSeparateLineCGColor;
_changeoverBtn.layer.borderWidth = 0.5;
_changeoverBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
_changeoverBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
_changeoverBtn.translatesAutoresizingMaskIntoConstraints = NO; _changeoverBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_changeoverBtn setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
_changeoverBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
[self addSubview:_changeoverBtn]; [self addSubview:_changeoverBtn];
// 顶端 // 顶端
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment