An open API service indexing awesome lists of open source software.

https://github.com/mengxianliang/xlslideswitch

iOS 仿照今日头条滚动列表
https://github.com/mengxianliang/xlslideswitch

slide switch tableview viewcontroller

Last synced: 2 months ago
JSON representation

iOS 仿照今日头条滚动列表

Awesome Lists containing this project

README

          

# 当前为老版本,新版本请移步[XLPageViewController](https://github.com/mengxianliang/XLPageViewController)

# XLSlideSwitch

### 显示效果:

| 样式 | 正常显示标题 | 在NavigationBar上显示标题 |
| ---- | ---- | --- |
|标准样式| | |
|Segmented样式| | |

### 原理简介:

顶部的标题栏是利用*UICollectionview*实现的;底部视图控制器的切换是利用*UIPageViewController*实现的。


最大化的优化内存的使用,每个*ChildViewController*都是随着滚动加载的,避免了同时加载引起的UI卡顿。

### 使用方法:

#### 1、创建数据源:titles、viewControllers

```objc
//要显示的标题
NSArray *titles = @[@"今天",@"是个",@"好日子",@"心想的",@"事儿",@"都能成",@"明天",@"是个",@"好日子",@"打开了家门",@"咱迎春风",@"~~~"];
//创建需要展示的ViewController
NSMutableArray *viewControllers = [NSMutableArray new];
for (int i = 0 ; i

2、设置Segmented横向缩进
```objc
_slideSwitch.horizontalInset = 50;
```

3、设置更多按钮
```objc
_slideSwitch.moreButton = [self moreButton];
```
```objc
- (UIButton *)moreButton {
UIButton *button = [[UIButton alloc] init];
[button setImage:[UIImage imageNamed:@"channelAdd"] forState:UIControlStateNormal];
[button setImageEdgeInsets:UIEdgeInsetsMake(8, 8, 8, 8)];
return button;
}
```

4、手动设置选中位置
```objc
_slideSwitch.selectedIndex = 3;
```

### 个人开发过的UI工具集合 [XLUIKit](https://github.com/mengxianliang/XLUIKit)