HTSegmentsView 0.0.3

HTSegmentsView 0.0.3

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年1月

Zeyu Tao 维护。



  • netease

HTSegmentsView 对一组子控件进行“单选”状态管理,并支持选中状态的切换与动画。

特性

  • 支持自定义子控件排版、样式
  • 支持状态切换过渡动画
  • 提供常见子控件及过渡动画

用法

(1)创建 SegmentsView 并设置其代理

HTSegmentsView *segmentsView = [[HTHorizontalSegmentsView alloc] initWithSelectedIndex:0];
segmentsView.frame = CGRectMake(30,100,260,50);
segmentsView.segmentsDelegate = self;

(2)创建并设置 DataSource

注意:segmentsView 内部对 datasource 是弱引用,使用者需要保证 datasource 的生命周期。

HTStringToLabelDataSource *dataSource = [[HTStringToLabelDataSource alloc] initWithArray:@[@"button1",@"button2",@"button3"] segmentCellClass:nil];
segmentsView.segmentsDataSource = dataSource;

(3)创建并设置过渡动画 HTSegmentsViewAnimator

HTSublineSegmentViewAnimator *animator = [[HTSublineSegmentViewAnimator alloc] initWithSegmentsView:segmentsView backgroundColor:[UIColor lightGrayColor] lineColor:[UIColor greenColor] lineHeight:5];
segmentsView.animator = animator;

注意:

HTSegmentsView 继承自 UIScrollView,为了避免 NavigationController 导致的 -64 的 contentOffset 问题,需要将 HTSegmentsView 所在 ViewController 的 automaticallyAdjustsScrollViewInsets 属性设置为 NO,或者在合适的时间将修改掉 HTSegmentsView 的 contentOffset 值。

安装

系统要求

该项目最低支持 iOS 7.0Xcode 7.0

许可证

HTSegmentsView 使用 MIT 许可证,详情见 LICENSE 文件。