全部产品
云市场
云游戏

纵向选择器

更新时间:2019-09-26 18:40:02

AUVerticalTabView 为纵向选择器组件。

效果图

依赖

AUVerticalTabView 的依赖如下:

  1. AntUI

接口说明

  1. #import <UIKit/UIKit.h>
  2. @protocol AUVerticalTabViewDataProtocol <NSObject>
  3. @required
  4. - (NSString *) tabName;
  5. @end
  6. @class AUVerticalTabView;
  7. typedef void (^AUVerticalTabSelectedCallback)(AUVerticalTabView *verticalTabView);
  8. @interface AUVerticalTabView : UIView
  9. /**
  10. 推荐初始化方法,布局参数为 AntDNA 规范:
  11. AUVerticalTabView : width=110pt
  12. TabCell : width=110pt,height=55pt
  13. @param verticalTabViewDatas 设置 tab 数据
  14. @param selectedCallback 设置点击回调
  15. @param height AUVerticalTabView 高度
  16. @param business 业务标示,如:GoldWord、BeeCityPicker
  17. @return AUVerticalTabView
  18. */
  19. + (AUVerticalTabView *)verticalTabViewWithDatas:(NSArray <id<AUVerticalTabViewDataProtocol>>*) verticalTabViewDatas
  20. selectedCallback:(AUVerticalTabSelectedCallback)selectedCallback
  21. height:(CGFloat)height
  22. business:(NSString *)business;
  23. @property(nonatomic, strong) NSArray <id<AUVerticalTabViewDataProtocol>>* verticalTabViewDatas;
  24. @property(nonatomic, assign) NSUInteger selectedIndex;//default 0
  25. @property(nonatomic, copy) AUVerticalTabSelectedCallback selectedCallback;
  26. @end

代码示例

  1. // 外部数据对象实现 AUVerticalTabViewDataProtocol,返回需要的 tabName
  2. @interface DemoVerticalTabData : NSObject <AUVerticalTabViewDataProtocol>
  3. - (NSString *)tabName;
  4. @end
  1. NSArray *datas = @[[DemoVerticalTabData new],
  2. [DemoVerticalTabData new],
  3. [DemoVerticalTabData new],
  4. [DemoVerticalTabData new],
  5. [DemoVerticalTabData new],
  6. [DemoVerticalTabData new],
  7. [DemoVerticalTabData new]];
  8. AUVerticalTabView *tabView = [AUVerticalTabView verticalTabViewWithDatas:datas
  9. selectedCallback:^(AUVerticalTabView *verticalTabView ){
  10. NSUInteger selectedIndex = verticalTabView.selectedIndex;
  11. id<AUVerticalTabViewDataProtocol> selectedData = [verticalTabView.verticalTabViewDatas objectAtIndex:selectedIndex];
  12. }
  13. height:self.view.height
  14. business:@"AntUI"];
  15. [self.view addSubview:tabView];