基本上,你會做類似如下:
@class CustomTabBar;
@protocol CustomTabBarDatasource <NSObject>
- (int)numberOfElementsInCustomTabBar:(CustomTabBar *)bar;
- (NSString *)titleForTabAtIndex:(int)index inCustomTabBar:(CustomTabBar *)bar;
@end
@protocol CustomTabBarDelegate <NSObject>
- (void)customTabBar:(CustomTabBar *)bar activatedTabAtIndex:(int)index;
@end
@interface CustomTabBar : UIView
@property (weak) id<CustomTabBarDataSource> dataSource;
@property (weak) id<CustomTabBarDelegate> delegate;
@end
@interface YourViewController : UIViewController {
CustomTabBar *myTabBar;
}
@end
@interface YourViewController (TabBarDataSource) <CustomTabBarDataSource>
@end
@interface YourViewController (TabBarDelegate) <CustomTabBarDelegate>
@end
您CustomTabBar
的實施將包括UIScrollView
和一組UIButton
S,其標題,你會找回從dataSource
。當一個按鈕被觸發時,你可以調用delegate
的customTabBar:activatedTabAtIndex:
方法。代理方法觸發時,您的YourViewController
將更改其內容。
你說這個控件是「毛刺」的。你看到什麼「毛刺」?我在運輸應用中使用了這個控件十個月,並沒有收到任何有關「毛刺」的投訴。 – 2014-10-18 16:21:44