iOS可复用控件之分段滚动控件HTSegmentedScrollView
2018-03-29 14:06
579 查看
分段滚动页面是一个比较常见的需求,我把我的实现方式封装了一下,方便以后重复使用。
实现效果:
GitHub地址:https://github.com/runThor/HTSegmentedScrollView
使用方式非常简单,添加segment的title以及添加滚动的view即可,代码如下:#import "HTSegmentedScrollView.h"
- (void)viewDidLoad {
[super viewDidLoad];
HTSegmentedScrollView *segView = [[HTSegmentedScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
[self.view addSubview:segView];
[segView addSegmentedItems:@[@"红色", @"黄色", @"蓝色"]]; // 添加title
UIView *redView = [[UIView alloc] init];
redView.backgroundColor = [UIColor redColor];
UIView *yellowView = [[UIView alloc] init];
yellowView.backgroundColor = [UIColor yellowColor];
UIView *blueView = [[UIView alloc] init];
blueView.backgroundColor = [UIColor blueColor];
[segView addScrollViews:@[redView, yellowView, blueView]]; // 添加滚动的view
}
实现效果:
GitHub地址:https://github.com/runThor/HTSegmentedScrollView
使用方式非常简单,添加segment的title以及添加滚动的view即可,代码如下:#import "HTSegmentedScrollView.h"
- (void)viewDidLoad {
[super viewDidLoad];
HTSegmentedScrollView *segView = [[HTSegmentedScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
[self.view addSubview:segView];
[segView addSegmentedItems:@[@"红色", @"黄色", @"蓝色"]]; // 添加title
UIView *redView = [[UIView alloc] init];
redView.backgroundColor = [UIColor redColor];
UIView *yellowView = [[UIView alloc] init];
yellowView.backgroundColor = [UIColor yellowColor];
UIView *blueView = [[UIView alloc] init];
blueView.backgroundColor = [UIColor blueColor];
[segView addScrollViews:@[redView, yellowView, blueView]]; // 添加滚动的view
}
相关文章推荐
- iOS实战-自定义的横向滚动控件CustomScrollView
- iOS可复用控件之修改SDCycleScrollView实现轮播图的缩放效果
- IOS的基本控件的使用-UIScrollView滚动视图的高级功能
- HorizontalScrollView设置默认值或者滚动到上面指定的控件
- 【Android 开发】:UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
- cocos2d实现类似CCMenu菜单类控件,在CCScrollView滚动, lua脚本控件
- iOS--分段控件UISegmentedControl
- android自定义控件-AutoScrollViewpager(无限滚动轮播控件)
- HorizontalScrollView 嵌套listview实现列表左右、上下滑动、控件复用等功能
- UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
- iOS 高性能异构滚动视图构建方案- LazyScrollView 详细用法
- 含有按钮的ScrollView在iOS8中无法滚动的解决办法 | ScrollView with UIControl/UIButton subviews not scrollable under iOS 8
- iOS设计—滚动页面的设计 (控件UIScrollView)
- IOS学习笔记(七)之UISegmentedControl分段控件的基本概念和使用方法
- iOS开发之 滚动视图 + 页面控件(UIScrollView + UIPageControl)
- iOS 6编程-UIScrollView滚动视图和UIPageControl分页控件的简单应用
- iOS 6编程-UIScrollView滚动视图和UIPageControl分页控件实现图像分页显示
- 一个封装好的iOS无限滚动组件HXInfiniteScrollView
- IOS学习笔记(七)之UISegmentedControl分段控件的基本概念和使用方法
- [置顶] cocos2d实现类似CCMenu菜单类控件,在CCScrollView滚动, lua脚本控件