#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];
}
分段选择
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 不是第一次在越秀公园看灯会,这么多人确实头一次。在不断上演脚尖睬脚跟的环境里,看得最多的是举手机拍照的人头。出图如下: