仿Uber筛选栏

项目截图
项目截图
这个是之前项目中用的,现在要改了,改之前把这个记录下来,万一有人用到了,就可以直接拿来用了,这个是在大神的基础上改的,还行吧,但是觉得有点丑!有需要的可以看一下,方法有点笨,大神勿喷!!!!
1.加载数据
 *  加载数据
 */
- (void)loadData{
    
    timeArray = @[@"6小时之内",@"12小时之内",@"24小时之内"];
    
    locationArray = @[@"全城",@"附近1km",@"附近3千米",@"附近5千米",@"附近10千米"];
    
    piceArray = @[@"价格不限",@"0-5元",@"5-20元",@"20-50元",@"50-100元"];
    
}
2.加载视图
 *  加载UI视图
 */
-(void)shuaxin{
    
    dicengbackeView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenHeight-140, kScreenWidth, 420)];
    
    dicengbackeView.backgroundColor = [UIColor colorWithWhite:0.850 alpha:1.000];
    
    [self.view addSubview:dicengbackeView];
    
    filter = [[SEFilterControlList alloc]initWithFrame:CGRectMake((kScreenWidth-300)/2, -5, 300, 30) Titles:[NSArray arrayWithObjects:@"时间", @"附近", @"价格",nil]];
    
    filter.userInteractionEnabled = YES;
    
    [filter addTarget:self action:@selector(filterValueChanged:) forControlEvents:UIControlEventTouchUpInside];
    
    [filter setProgressColor:[UIColor groupTableViewBackgroundColor]];//设置滑杆的颜色
    
    [filter setTitlesFont:[UIFont fontWithName:@"Didot" size:16]];
    
    [filter setTopTitlesColor:[UIColor blackColor]];//设置滑块上方字体颜色
    
    [filter setSelectedIndex:0];//设置当前选中
    
    [dicengbackeView addSubview:filter];
    
    
    Button_UIView  = [[UIView alloc]initWithFrame:CGRectMake(0, 70,kScreenWidth,240)];
    
    Button_UIView.backgroundColor = [UIColor colorWithWhite:0.730 alpha:1.000];
    
    [dicengbackeView addSubview:Button_UIView];
    
    _backsrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0,kScreenWidth , 240)];
    
    _backsrollView.pagingEnabled = YES;
    
    _backsrollView.userInteractionEnabled = YES;
    
    _backsrollView.contentSize =CGSizeMake(kScreenWidth*3, 0);
    //设置是否滚动
    _backsrollView.scrollEnabled = NO;
    
    [Button_UIView addSubview:_backsrollView];
    
    imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, _backsrollView.frame.size.height)];
    
    imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, _backsrollView.frame.size.height)];
    
    imageView3 = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth*2, 0, kScreenWidth, _backsrollView.frame.size.height)];
#pragma mark ==========Loading===================
    imageView1.userInteractionEnabled = YES;
    
    imageView2.userInteractionEnabled = YES;
    
    imageView3.userInteractionEnabled = YES;
    
#pragma mark ==========Loading===================
    for (int g =0; g<3; g++) {
        
        UIButton *button1 = [UIButton  buttonWithType:UIButtonTypeCustom];
        
        button1.frame = CGRectMake(0, (180/3)*g, kScreenWidth, 180/3);
        button1.backgroundColor = [UIColor colorWithWhite:0.850 alpha:1.000];
        
        [button1 setTitle:timeArray[g] forState:UIControlStateNormal];
        
        [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        button1.tag = 100+g;
        
        button1.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        button1.layer.borderColor = [[UIColor colorWithWhite:0.837 alpha:1.000] CGColor];
        
        button1.layer.borderWidth = 1.0f;
        
        [button1 addTarget:self action:@selector(timebtn:) forControlEvents:UIControlEventTouchUpInside];
        
        [imageView1 addSubview:button1];
        
    }
    
    for (int k =0; k<5; k++) {
        
        UIButton *button2 = [UIButton  buttonWithType:UIButtonTypeCustom];
        
        button2.frame = CGRectMake(0, (180/5)*k, kScreenWidth, 180/5);
        button2.backgroundColor = [UIColor colorWithWhite:0.850 alpha:1.000];
        
        [button2 setTitle:locationArray[k] forState:UIControlStateNormal];
        
        [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        button2.tag = 200+k;
        
        button2.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        button2.layer.borderColor = [[UIColor colorWithWhite:0.837 alpha:1.000] CGColor];
        
        button2.layer.borderWidth = 1.0f;
        
        [imageView2 addSubview:button2];
        
        [button2 addTarget:self action:@selector(timebtn:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    for (int y =0; y<5; y++) {
        
        UIButton *button3 = [UIButton  buttonWithType:UIButtonTypeCustom];
        
        button3.frame = CGRectMake(0, (180/5)*y, kScreenWidth, 180/5);
        
        button3.backgroundColor = [UIColor colorWithWhite:0.850 alpha:1.000];
        
        [button3 setTitle:piceArray[y] forState:UIControlStateNormal];
        
        [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        button3.tag = 300+y;
        
        button3.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        button3.layer.borderColor = [[UIColor colorWithWhite:0.837 alpha:1.000] CGColor];
        
        button3.layer.borderWidth = 1.0f;
        
        [imageView3 addSubview:button3];
        
        [button3 addTarget:self action:@selector(timebtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    [_backsrollView addSubview:imageView1];
    
    [_backsrollView addSubview:imageView2];
    
    [_backsrollView addSubview:imageView3];
    
}

- (void)filterValueChanged:(SEFilterControlList *)sender{
    
    NSLog(@"%d",sender.SelectedIndex);
    switch (sender.SelectedIndex) {
        case 0:{
            
            break;
        }
        case 1:{
            
            break;
        }
        case 2:{
            
            break;
        }
        default:
            break;
    }
    
    _backsrollView.contentOffset = CGPointMake([sender SelectedIndex]*kScreenWidth, 0);
    
//    self.table.contentInset = UIEdgeInsetsMake(0, 0, 230, 0);
    
    [UIView animateWithDuration:0.2 animations:^{
        
        
        [UIView animateWithDuration:0.2 animations:^{
            
            dicengbackeView.frame = CGRectMake(0,kScreenHeight-310 , kScreenWidth,310);
        }];
        
        
    } completion:^(BOOL finished) {
        
    }];
    
}


- (void)timebtn:(UIButton *)sender{
    
    switch (sender.tag) {
        case  100:{
            
            [shaixuan setObject:@"6" forKey:@"times"];
            
            [self dianji];
            [self chuanzhi];
            
            break;
        }
        case  101:{
            
            
            
            [shaixuan setObject:@"12" forKey:@"times"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            break;
        }
        case  102:{
            
            [shaixuan setObject:@"24" forKey:@"times"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            break;
        }
            
        case  200:{
            
            
            [shaixuan setObject:@"0" forKey:@"nearby"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
            
        case  201:{
            
            
            
            [shaixuan setObject:@"1" forKey:@"nearby"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
            
        case  202:{
            
            
            
            [shaixuan setObject:@"3" forKey:@"nearby"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
            
            
        case  203:{
            
            
            
            [shaixuan setObject:@"5" forKey:@"nearby"];
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
            
            
        case  204:{
            
            
            
            [shaixuan setObject:@"10" forKey:@"nearby"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
            
        case  300:{
            
            
            
            [shaixuan setObject:@"0" forKey:@"pricenumber"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
        case  301:{
            
            
            
            [shaixuan setObject:@"1" forKey:@"pricenumber"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            break;
        }
        case  302:{
            
            
            
            [shaixuan setObject:@"2" forKey:@"pricenumber"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
        case  303:{
            
            [shaixuan setObject:@"3" forKey:@"pricenumber"];
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
        case  304:{
            
            [shaixuan setObject:@"4" forKey:@"pricenumber"];
            
            
            [self dianji];
            //            [self  pianyi];
            [self chuanzhi];
            
            break;
        }
        default:
            break;
    }
#pragma mark ===================
    
}


-(void)dianji{
    
    
    [UIView animateWithDuration:0.2 animations:^{
        
        dicengbackeView.frame = CGRectMake(0, kScreenHeight-135, kScreenWidth, 370);
    }];
}
//将参数传给后台,请求数据
-(void)chuanzhi{
    
    
}

github 地址 https://github.com/chenyang-ios/Uber-shaixuan.git
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容