iOS仿Uber筛选栏效果

这个是之前项目中用的仿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{

}

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

(0)

相关推荐

  • AngularJs页面筛选标签小功能

    AngularJS 简介 AngularJS 是一个 JavaScript 框架.它可通过 <script> 标签添加到 HTML 页面. AngularJS 通过 指令 扩展了 HTML,且通过 表达式 绑定数据到 HTML. AngularJS 是一个 JavaScript 框架 AngularJS 是一个 JavaScript 框架.它是一个以 JavaScript 编写的库. AngularJS 是以一个 JavaScript 文件形式发布的,可通过 script 标签添加到网页中:

  • angularjs 实现带查找筛选功能的select下拉框实例

    一.背景 对于select的下拉列表,像国家选择这样的功能,全世界那么多国家,一直拉滚动条多辛苦,眼睛也要盯着找,累!so,为优化用户体验,带查找功能的下拉框是非常非常有必要的.都知道jquery里有这样的插件,但我们用的是Angularjs,更希望用双向绑定,指令的方式优雅地解决这个问题. 分析:    目标 在原来的<select ng-options="">标签上新加一个属性 select-search 就能支持查找的功能.如果这个属性没起作用,也不影响原来的sele

  • angular实现商品筛选功能

    一.demo功能分析 1.通过service()创建数据并遍历渲染到页面 2.根据输入框的输入值进行字段查询 3.点击各列实现排序功能. 二.实现 1.1 数据定义与渲染 angular更偏向于是一个MVVM模式的框架,所以它的controller很薄,里面的业务逻辑也是少的,因此应该养成把逻辑写在service或者Factory等angular提供的可以自定义服务的方法中.此次demo通过angular的service方法来注册并定义商品数据. angular.module("app"

  • jquery遍历筛选数组的几种方法和遍历解析json对象

    jquery grep()筛选遍历数组 复制代码 代码如下: $().ready( function(){ var array = [1,2,3,4,5,6,7,8,9]; var filterarray = $.grep(array,function(value){ return value > 5;//筛选出大于5的 }); for(var i=0;i<filterarray.length;i++){ alert(filterarray[i]); } for (key in filtera

  • JQuery筛选器全系列介绍

    1.选择对象 1).基本 ·#id 根据给定的ID匹配一个元素.例如:$("#id")·element 根据给定的元素名匹配所有元素.例如:$("div")·.class 根据给定的类匹配元素.例如:$(".style1");·* 匹配所有元素.例如:$("*")·selector1,selector2,selectorN 将每一个选择器匹配到的元素合并后一起返回.例如:$("#id,div,.style1"

  • jquery遍历数组与筛选数组的方法

    grepgrep()方法用于数组元素过滤筛选 grep(array,callback,invert)array:待过滤数组;callback:处理数组中的每个元素,并过滤元素,该函数中包含两个参数,第一个是当前数组元素的值,一个是当前数组元素的下标,即元素索引值.此函数应返回一个布尔值.另外,此函数可设置为一个字符串,当设置为字符串时,将视为"lambda-form"(缩写形式?),其中 a 代表数组元素,i 代表元素索引值.如"a > 0"代表"f

  • js实现表格筛选功能

    本应用就两个主要实现: 1.表格的id 和 class之间的命名关系 请看图: 将组名和个人信息联表格联系起来,这样会很好的操作表格 HTML代码: <tr class="parent" id="row_01"><td colspan="3">前台设计组</td></tr> <tr class="child_row_01"><td>张三</td>

  • Angularjs实现带查找筛选功能的select下拉框示例代码

    前言 对于select的下拉列表,像国家选择这样的功能,全世界那么多国家,一直拉滚动条多辛苦,眼睛也要盯着找,累!所以为优化用户体验,带查找功能的下拉框是非常非常有必要的.都知道jquery里有这样的插件,但我们用的是Angularjs,更希望用双向绑定,指令的方式优雅地解决这个问题. 分析 我们的目标是在原来的<select ng-options="">标签上新加一个属性 select-search 就能支持查找的功能.如果这个属性没起作用,也不影响原来的select的功

  • Jquery仿淘宝京东多条件筛选可自行结合ajax加载示例

    复制代码 代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="JquerySort.aspx.cs" Inherits="demo_JquerySort" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www

  • jQuery筛选器children()案例详解(图文)

    jQuery的选择包含两种,一种是选择器,一种是筛选器.筛选器是对选择器选定的jQuery对象做进一步选择. children()是一个筛选器,顾名思义就是筛选孩子,筛选那些符合条件的孩子. 完整的格式如下: 复制代码 代码如下: .children(expr) 其中children是筛选器的名称,expr是表达式,所有选择器中的表达式都可以用在这,比如按标签名"div",按类名".class",按序号":first"等等,如果表达式为空,那么返

随机推荐