All Products
Search
Document Center

Vertical tab

Last Updated: May 13, 2021

AUVerticalTabView is a vertical tab-based component.

Sample image

Dependency

The dependency of AUVerticalTabView is as follows:

 
  1. AntUI

API description

 
  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. The recommended initialization method. The layout parameters are standardized by AntDNA.
  11. AUVerticalTabView : width=110pt
  12. TabCell : width=110pt,height=55pt
  13. @param verticalTabViewDatas Set tab data.
  14. @param selectedCallback Set the tapping event callback.
  15. @param height The height of AUVerticalTabView.
  16. @param business The business identifier, such as GoldWord or 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

Code sample

 
  1. // The external data object implementation AUVerticalTabViewDataProtocol, which returns the required 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];