服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - IOS - iOS仿Uber筛选栏效果

iOS仿Uber筛选栏效果

2021-03-03 15:52飞翔云端的鱼 IOS

这篇文章主要为大家详细介绍了iOS仿Uber筛选栏的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

这个是之前项目中用的仿Uber筛选栏,现在要改了,改之前把这个记录下来,万一有人用到了,就可以直接拿来用了,这个是在大神的基础上改的,还行吧,但是觉得有点丑!有需要的可以看一下,方法有点笨,大神勿喷。

iOS仿Uber筛选栏效果

iOS仿Uber筛选栏效果

1.加载数据

?
1
2
3
4
5
6
7
8
* 加载数据
 */
- (void)loadData{
 timeArray = @[@"6小时之内",@"12小时之内",@"24小时之内"];
 locationArray = @[@"全城",@"附近1km",@"附近3千米",@"附近5千米",@"附近10千米"];
 piceArray = @[@"价格不限",@"0-5元",@"5-20元",@"20-50元",@"50-100元"];
 
}

2.加载视图

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
* 加载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{
 
 
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://www.jianshu.com/p/90e24151a7bf

延伸 · 阅读

精彩推荐
  • IOSiOS 雷达效果实例详解

    iOS 雷达效果实例详解

    这篇文章主要介绍了iOS 雷达效果实例详解的相关资料,需要的朋友可以参考下...

    SimpleWorld11022021-01-28
  • IOSiOS中tableview 两级cell的展开与收回的示例代码

    iOS中tableview 两级cell的展开与收回的示例代码

    本篇文章主要介绍了iOS中tableview 两级cell的展开与收回的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    J_Kang3862021-04-22
  • IOSIOS 屏幕适配方案实现缩放window的示例代码

    IOS 屏幕适配方案实现缩放window的示例代码

    这篇文章主要介绍了IOS 屏幕适配方案实现缩放window的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要...

    xiari5772021-06-01
  • IOSIOS开发之字典转字符串的实例详解

    IOS开发之字典转字符串的实例详解

    这篇文章主要介绍了IOS开发之字典转字符串的实例详解的相关资料,希望通过本文能帮助到大家,让大家掌握这样的方法,需要的朋友可以参考下...

    苦练内功5832021-04-01
  • IOS关于iOS自适应cell行高的那些事儿

    关于iOS自适应cell行高的那些事儿

    这篇文章主要给大家介绍了关于iOS自适应cell行高的那些事儿,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的...

    daisy6092021-05-17
  • IOS解析iOS开发中的FirstResponder第一响应对象

    解析iOS开发中的FirstResponder第一响应对象

    这篇文章主要介绍了解析iOS开发中的FirstResponder第一响应对象,包括View的FirstResponder的释放问题,需要的朋友可以参考下...

    一片枫叶4662020-12-25
  • IOSiOS通过逆向理解Block的内存模型

    iOS通过逆向理解Block的内存模型

    自从对 iOS 的逆向初窥门径后,我也经常通过它来分析一些比较大的应用,参考一下这些应用中某些功能的实现。这个探索的过程乐趣多多,不仅能满足自...

    Swiftyper12832021-03-03
  • IOSiOS布局渲染之UIView方法的调用时机详解

    iOS布局渲染之UIView方法的调用时机详解

    在你刚开始开发 iOS 应用时,最难避免或者是调试的就是和布局相关的问题,下面这篇文章主要给大家介绍了关于iOS布局渲染之UIView方法调用时机的相关资料...

    windtersharp7642021-05-04