AUVerticalTabView 为纵向选择器组件。
效果图
依赖
AUVerticalTabView 的依赖如下:
AntUI
接口说明
#import <UIKit/UIKit.h>
@protocol AUVerticalTabViewDataProtocol <NSObject>
@required
- (NSString *) tabName;
@end
@class AUVerticalTabView;
typedef void (^AUVerticalTabSelectedCallback)(AUVerticalTabView *verticalTabView);
@interface AUVerticalTabView : UIView
/**
推荐初始化方法,布局参数为 AntDNA 规范:
AUVerticalTabView : width=110pt
TabCell : width=110pt,height=55pt
@param verticalTabViewDatas 设置 tab 数据
@param selectedCallback 设置点击回调
@param height AUVerticalTabView 高度
@param business 业务标示,如:GoldWord、BeeCityPicker
@return AUVerticalTabView
*/
+ (AUVerticalTabView *)verticalTabViewWithDatas:(NSArray <id<AUVerticalTabViewDataProtocol>>*) verticalTabViewDatas
selectedCallback:(AUVerticalTabSelectedCallback)selectedCallback
height:(CGFloat)height
business:(NSString *)business;
@property(nonatomic, strong) NSArray <id<AUVerticalTabViewDataProtocol>>* verticalTabViewDatas;
@property(nonatomic, assign) NSUInteger selectedIndex;//default 0
@property(nonatomic, copy) AUVerticalTabSelectedCallback selectedCallback;
@end
代码示例
// 外部数据对象实现 AUVerticalTabViewDataProtocol,返回需要的 tabName
@interface DemoVerticalTabData : NSObject <AUVerticalTabViewDataProtocol>
- (NSString *)tabName;
@end
NSArray *datas = @[[DemoVerticalTabData new],
[DemoVerticalTabData new],
[DemoVerticalTabData new],
[DemoVerticalTabData new],
[DemoVerticalTabData new],
[DemoVerticalTabData new],
[DemoVerticalTabData new]];
AUVerticalTabView *tabView = [AUVerticalTabView verticalTabViewWithDatas:datas
selectedCallback:^(AUVerticalTabView *verticalTabView ){
NSUInteger selectedIndex = verticalTabView.selectedIndex;
id<AUVerticalTabViewDataProtocol> selectedData = [verticalTabView.verticalTabViewDatas objectAtIndex:selectedIndex];
}
height:self.view.height
business:@"AntUI"];
[self.view addSubview:tabView];
文档内容是否对您有帮助?