#import "ViewController.h"
#import "MDMultipleSegmentView.h"
#import "MDFlipCollectionView.h"
@interface ViewController ()<MDMultipleSegmentViewDeletegate,
MDFlipCollectionViewDelegate>
{
MDMultipleSegmentView *_segView;
MDFlipCollectionView *_collectView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor whiteColor];
self.edgesForExtendedLayout = UIRectEdgeNone;
_segView = [[MDMultipleSegmentView alloc] init];
_segView.delegate = self;
_segView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 44);
_segView.items = @[@"东",@"南", @"西", @"北", @"日", @"月"];
[self.view addSubview:_segView];
NSArray *arr = @[[self controller],
[self controller],
[self controller],
[self controller],
[self controller],
[self controller],
];
_collectView = [[MDFlipCollectionView alloc] initWithFrame:CGRectMake(0,
CGRectGetMaxY(_segView.frame),
CGRectGetWidth(_segView.frame),
CGRectGetHeight(self.view.bounds) - CGRectGetMaxY(_segView.frame)) withArray:arr];
_collectView.delegate = self;
[self.view addSubview:_collectView];
}
- (UIViewController *)controller
{
UIViewController *vc = [[UIViewController alloc] init];
CGFloat red = arc4random() / (CGFloat)INT_MAX;
CGFloat green = arc4random() / (CGFloat)INT_MAX;
CGFloat blue = arc4random() / (CGFloat)INT_MAX;
vc.view.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
return vc;
}
- (void)changeSegmentAtIndex:(NSInteger)index
{
[_collectView selectIndex:index];
}
- (void)flipToIndex:(NSInteger)index
{
[_segView selectIndex:index];
}
分段选择
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 不是第一次在越秀公园看灯会,这么多人确实头一次。在不断上演脚尖睬脚跟的环境里,看得最多的是举手机拍照的人头。出图如下: