iOS仿Uber筛选栏效果

 更新时间:2017年01月22日 17:03:11   作者:飞翔云端的鱼  
这篇文章主要为大家详细介绍了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{


}

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

相关文章

  • iOS中Sqlite和FMDB使用详解

    iOS中Sqlite和FMDB使用详解

    这篇文章主要为大家介绍了iOS中Sqlite和FMDB使用方法详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-10-10
  • IOS提醒用户重新授权打开定位功能

    IOS提醒用户重新授权打开定位功能

    这篇文章主要介绍了IOS提醒用户重新授权打开定位功能的相关资料,需要的朋友可以参考下
    2015-12-12
  • iOS应用开发中运用设计模式中的组合模式的实例解析

    iOS应用开发中运用设计模式中的组合模式的实例解析

    这篇文章主要介绍了iOS应用开发中运用设计模式中的组合模式的实例解析,示例代码为传统的Objective-C,需要的朋友可以参考下
    2016-03-03
  • IOS绘制虚线的方法总结

    IOS绘制虚线的方法总结

    这篇文章给大家分享了iOS中绘制虚线常见的几种方式,大家可以根据自己的需求进行选择哪种方法,下面跟着小编来一起看看吧。
    2016-09-09
  • iOS 11 下适配UITableView 问题

    iOS 11 下适配UITableView 问题

    这篇文章主要介绍了iOS 11 下适配UITableView 问题,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2017-09-09
  • iOS面试中如何优雅回答Block导致循环引用的问题

    iOS面试中如何优雅回答Block导致循环引用的问题

    这篇文章主要给大家介绍了iOS面试中关于如何优雅回答Block导致循环引用的问题的相关资料,文中通过图文介绍的非常相信,相信对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。
    2017-03-03
  • iOS实现简单分栏效果

    iOS实现简单分栏效果

    这篇文章主要为大家详细介绍了iOS实现简单分栏效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-03-03
  • IOS 仿Android吐司提示框的实例(分享)

    IOS 仿Android吐司提示框的实例(分享)

    下面小编就为大家分享一篇IOS 仿Android吐司提示框的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2017-12-12
  • 利用iOS实现系统相册大图浏览功能详解

    利用iOS实现系统相册大图浏览功能详解

    查看大图是们日常开发中经常会遇到的一个需求,下面这篇文章主要给大家介绍了关于利用iOS实现系统相册大图浏览功能的相关资料,文中给出了详细的示例代码供大家参考学习,需要的朋友们下面来一起看看吧。
    2017-09-09
  • iOS中Block的回调使用和解析详解

    iOS中Block的回调使用和解析详解

    刚刚进入iOS开发行业,发现开发中要用到大量的block回调,由此可见它的重要性。本文主要讲的是 Block 回调的使用,以及 Block 是如何实现这种神奇的回调两部分来讲的,下面来一起看看吧。
    2016-09-09

最新评论