小編給大家分享一下iOS如何實現(xiàn)仿Uber篩選欄效果,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)是一家專業(yè)提供武清企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、做網(wǎng)站、H5頁面制作、小程序制作等業(yè)務(wù)。10年已為武清眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。1.加載數(shù)據(jù)
* 加載數(shù)據(jù) */ - (void)loadData{ timeArray = @[@"6小時之內(nèi)",@"12小時之內(nèi)",@"24小時之內(nèi)"]; 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]];//設(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è)置是否滾動 _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ù)傳給后臺,請求數(shù)據(jù) -(void)chuanzhi{ }
以上是“iOS如何實現(xiàn)仿Uber篩選欄效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站aaarwkj.com,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)站題目:iOS如何實現(xiàn)仿Uber篩選欄效果-創(chuàng)新互聯(lián)
文章地址:http://aaarwkj.com/article42/ccjchc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、搜索引擎優(yōu)化、外貿(mào)網(wǎng)站建設(shè)、電子商務(wù)、全網(wǎng)營銷推廣、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)