你可以使用 CocoaPods 安装 ZKSegment
,在你的 Podfile
中添加:
platform :ios, '8.0'
target 'MyApp' do
pod 'ZKSegment', '1.0.3'
end
#import "ZKSegment.h"`
_ZKSegment = [ZKSegment
zk_segmentWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 45)
style:ZKSegmentLineStyle];
_ZKSegment.zk_itemClickBlock=^(NSString *itemName , NSInteger itemIndex){
NSLog(@"click item:%@",itemName);
NSLog(@"click itemIndex:%d",itemIndex);
};
[_ZKSegment zk_setItems:@[ @"菜单1", @"菜单2" ]];
[self.view addSubview:_ZKSegment];
###属性
zk_itemDefaultColor
设置每一项文本默认颜色
zk_itemSelectedColor
设置每一项文本选中颜色
zk_itemStyleSelectedColor
选中项样式颜色
zk_backgroundColor
背景色