WDScrollableSegmentedControl 0.1.2

WDScrollableSegmentedControl 0.1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2017年9月

Wildog维护。




最小化分段控件,可滚动,可定制,可动,使用极其简单。

YTPageController配合工作得很好

Screenshot

用法

仅需使用界面 Builder

IB

... 或者您更喜欢代码

WDScrollableSegmentedControl *segmentedControl = [[WDScrollableSegmentedControl alloc] initWithFrame:frame];

// space between buttons
segmentedControl.padding = 10.;

// space before first button and after last button
segmentedControl.edgeMargin = 0.;

// indicator height
segmentedControl.indicatorHeight = 3.;

// indicator animation duration
segmentedControl.indicatorMoveDuration = 0.25;

// font
segmentedControl.font = [UIFont systemFontOfSize:16.];

// colors
segmentedControl.indicatorColor = [UIColor blackColor];
segmentedControl.buttonColor = [UIColor blackColor];
segmentedControl.buttonHighlightColor = [UIColor grayColor];
segmentedControl.buttonSelectedColor = [UIColor blueColor];

// use this method if you want to change colors dynamically
[segmentedControl setButtonColor:[UIColor greenColor] forState:UIControlStateNormal];

最后设置数据和代理

scrollSegment.buttons = @[@"Foo", @"Button 1", @"Button 2", @"Another Button", @"Bar", @"Button Again", @"Finally"];
scrollSegment.delegate = self;

// this is what your delegate should implement
- (void)didSelectButtonAtIndex:(NSInteger)index;

如果您在使用导航控制器,别忘了设置

self.automaticallyAdjustsScrollViewInsets = NO;

否则会干扰分段控件的内容大小

示例

要运行示例项目,先从仓库中克隆该副本,然后在Example目录中运行pod install

要求

iOS 8.0或更高版本。

安装

WDScrollableSegmentedControl可通过CocoaPods获得。要安装它,只需将以下行添加到Podfile中

pod "WDScrollableSegmentedControl"

作者

Wildog, [email protected]

许可证

WDScrollableSegmentedControl可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。