EHHorizontalSelectionView 1.3.0

EHHorizontalSelectionView 1.3.0

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2017年8月

Danila Gusev 维护。



  • 作者:
  • Danila Gusev

这是用于展示项目列表(水平表格)的扩展

安装

手动

将 EHHorizontalSelectionView 中的文件添加到您的项目中

用法

#import <EHHorizontalSelectionView/EHHorizontalSelectionView.h>

您可以将 EHHorizontalSelectionView 作为 xib 或 storyboard 中的出口使用

@property (nonatomic, weak) IBOutlet EHHorizontalSelectionView * hSelView;

表格的默认样式是使用 EHHorizontalViewCell 单元格。要更改默认行为,您需要注册另一个单元格类或单元格 nib。自定义单元格必须从 EHHorizontalViewCell 衍生。

例如具有动画选择的单元格类型

[_hSelView registerCellWithClass:[EHHorizontalLineViewCell class]];

[_hSelView1 registerCellWithClass:[EHRoundedHorizontalViewCell class]];

或您的自定义单元格

[_hSelView2 registerCellNib:[UINib nibWithNibName:@"MyCustomCellNib" bundle:nil] withClass:[EHHorizontalViewCell class]];

设置委托

_hSelView1.delegate = self;

委托需要获取选择视图所需的数据

- (NSUInteger)numberOfItemsInHorizontalSelection:(EHHorizontalSelectionView*)hSelView
- (NSString *)titleForItemAtIndex:(NSUInteger)index forHorisontalSelection:(EHHorizontalSelectionView*)hSelView

以及接收选择事件

- (void)horizontalSelection:(EHHorizontalSelectionView * _Nonnull)hSelView didSelectObjectAtIndex:(NSUInteger)index;

技巧

当有 "UICollectionViewFlowLayout 的工作方式没有定义,因为:" 时可能有助于

self.automaticallyAdjustsScrollViewInsets = NO;

自定义

IB 自定义

在 1.3.0 之后,您可以使用 IB 来更改选择视图的外观。提供了一套属性,可以更改视图的外观。 EHHorizontalSelcetionView 现在标记为 IBDesignable,您可以在 xib 或 storyboard 中看到自定义

颜色

您可以更改选定类型单元格的默认色调颜色

[EHHorizontalLineViewCell updateTintColor:[UIColor colorWithHex:0x00c264]];

您可以通过子类化该类型的单元格并重写方法 + (UIColor * _Nonnull)tintColor; 来实现

+ (UIColor *)tintColor
{
  return [UIColor redColor];
}

或者您可以更改所选选择视图的着色颜色

    [_hSelView2 setTintColor:[UIColor colorWithHex:0xff46c7]];

字体

更改默认外观

[EHRoundedHorizontalViewCell updateFontMedium:[UIFont boldSystemFontOfSize:15]];
[EHRoundedHorizontalViewCell updateFont:[UIFont systemFontOfSize:15]];

更改所选选择视图

[_hSelView3 setFont:[UIFont systemFontOfSize:17]];

单元格(内边距)的额外宽度

更改默认外观

[EHHorizontalLineViewCell updateCellGap:20];

更改所选选择视图

[_hSelView3 setCellGap:15.f];    

行高(针对 EHHorizontalLineViewCell)

[EHHorizontalLineViewCell updateColorHeight:2];

作者

Danila Gusev

[email protected]

许可证

使用受 MIT 许可证约束。有关详细信息,请参阅MIT 许可证。请在LICENSE中查看。