iOS仿Uber篩選欄效果
這個(gè)是之前項(xiàng)目中用的仿Uber篩選欄,現(xiàn)在要改了,改之前把這個(gè)記錄下來,萬一有人用到了,就可以直接拿來用了,這個(gè)是在大神的基礎(chǔ)上改的,還行吧,但是覺得有點(diǎn)丑!有需要的可以看一下,方法有點(diǎn)笨,大神勿噴。


1.加載數(shù)據(jù)
* 加載數(shù)據(jù)
*/
- (void)loadData{
timeArray = @[@"6小時(shí)之內(nèi)",@"12小時(shí)之內(nèi)",@"24小時(shí)之內(nèi)"];
locationArray = @[@"全城",@"附近1km",@"附近3千米",@"附近5千米",@"附近10千米"];
piceArray = @[@"價(jià)格不限",@"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:@"時(shí)間", @"附近", @"價(jià)格",nil]];
filter.userInteractionEnabled = YES;
[filter addTarget:self action:@selector(filterValueChanged:) forControlEvents:UIControlEventTouchUpInside];
[filter setProgressColor:[UIColor groupTableViewBackgroundColor]];//設(shè)置滑桿的顏色
[filter setTitlesFont:[UIFont fontWithName:@"Didot" size:16]];
[filter setTopTitlesColor:[UIColor blackColor]];//設(shè)置滑塊上方字體顏色
[filter setSelectedIndex:0];//設(shè)置當(dāng)前選中
[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);
//設(shè)置是否滾動(dòng)
_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);
}];
}
//將參數(shù)傳給后臺(tái),請(qǐng)求數(shù)據(jù)
-(void)chuanzhi{
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- angularjs 實(shí)現(xiàn)帶查找篩選功能的select下拉框?qū)嵗?/a>
- Angularjs實(shí)現(xiàn)帶查找篩選功能的select下拉框示例代碼
- AngularJs頁面篩選標(biāo)簽小功能
- js實(shí)現(xiàn)表格篩選功能
- jquery遍歷數(shù)組與篩選數(shù)組的方法
- jquery遍歷篩選數(shù)組的幾種方法和遍歷解析json對(duì)象
- JQuery篩選器全系列介紹
- Jquery仿淘寶京東多條件篩選可自行結(jié)合ajax加載示例
- jQuery篩選器children()案例詳解(圖文)
- angular實(shí)現(xiàn)商品篩選功能
相關(guān)文章
iOS 封裝導(dǎo)航欄及返回,獲取控件所在控制器的實(shí)例
下面小編就為大家分享一篇iOS 封裝導(dǎo)航欄及返回,獲取控件所在控制器的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-01-01
iOS 解決UICollectionView 計(jì)算 Cell 大小的問題
本文主要介紹iOS UICollectionView,這里給大家一個(gè)實(shí)例代碼作為參考,并指出經(jīng)常遇到的問題和解決辦法,希望能幫助有需要的小伙伴2016-07-07
解決JSON數(shù)據(jù)因?yàn)閚ull導(dǎo)致數(shù)據(jù)加載失敗的方法
前段時(shí)間發(fā)現(xiàn)一個(gè)問題,當(dāng)JSON數(shù)據(jù)中有null會(huì)導(dǎo)致數(shù)據(jù)加載失敗,后來解決了,現(xiàn)在將解決方法分享給大家,有同樣問題的朋友們可以參考。下面來一起看看吧。2016-09-09
詳解使用Xcode7的Instruments檢測(cè)解決iOS內(nèi)存泄露(最新)
本篇文章主要介紹使用Xcode7的Instruments檢測(cè)解決iOS內(nèi)存泄露(最新)的相關(guān)資料,需要的朋友可以參考下2017-09-09
IOS之構(gòu)造方法與自定義構(gòu)造方法的區(qū)別與實(shí)現(xiàn)
本篇文章主要介紹了構(gòu)造方法以及自定義構(gòu)造方法的實(shí)現(xiàn),需要的朋友可以參考下2015-07-07
詳解iOS開發(fā)中Keychain的相關(guān)使用
這篇文章主要介紹了iOS開發(fā)中Keychain的相關(guān)使用,文中列舉了一個(gè)使用Keychain來保存密碼的例子,需要的朋友可以參考下2015-10-10

