首页 > 解决方案 > 如何在 TabBar 中删除和重置顶行 - 适用于 iOS 13+

问题描述

我正在尝试在 iOS 13.2.2 中删除 TabBar 中的顶行,但对于 iOS 13.2.2,以下帖子中的这些答案都不再适用

链接 -从 TabBar 中删除顶行

  1. 最近有 API 变化吗?

  2. 如何在 iOS 13.2.2 中删除和重置 TabBar 的顶行?

标签: iosobjective-cswiftuitabbar

解决方案


如果您编写自己的 TabBar 类以确保您可以进行所有您想要的更改,那总是会更好。

#import "ViewController.h"

@protocol TabBarDelegate;

@interface TabBar : UIView{
    id<TabBarDelegate> delegate;
    UIView *backgroundView;
    UIButton *btn1;
    UIButton *btn2;

    UIImageView *img1;
    UIImageView *img2;

    UIView *hubHolder;

}

@property (nonatomic, retain) UIView *backgroundView;
@property (nonatomic, retain) id<TabBarDelegate> delegate;
@property (nonatomic, retain) UIButton *btn1;
@property (nonatomic, retain) UIButton *btn2;

@property (nonatomic, retain) UIImageView *img1;
@property (nonatomic, retain) UIImageView *img2;

- (id) initWithFrame:(CGRect)frame;

@end

@protocol TabBarDelegate<NSObject>

@optional
- (void) tabbarTapped:(int)index;

@end

您可以轻松地定义一个带有按钮的视图(按钮编号取决于您想通过标签栏访问多少个控制器)并委托控制是否点击了其中一个按钮。由于这是一个 UIView,您可以操纵它的外观。我希望它有所帮助。


推荐阅读