是否可以在 iPad 的 UITabBar 中添加按钮?

发布于 2024-10-11 21:54:42 字数 85 浏览 4 评论 0原文

我想知道是否可以在 iPad 上的 UITabBar 中添加 UIButton 。如果是这样,请告诉我。

I want to know if it is possible to add an UIButton in UITabBar on the iPad. If so, please let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我太投入 2024-10-18 21:54:42

如果您查看 @Kyle the Unruly 建议的文档,这是相当简单的。

以下是添加内置按钮和您自己的图像的示例:

UIBarButtonItem * viewSnapShotButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(snapShotButtonPressed:)];
UIBarButtonItem * fontButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Font.png"] style:UIBarButtonItemStylePlain target:self action: @selector(fontSize:)];

// Add buttons to the tab bar
NSMutableArray *topCentreItems = [[NSMutableArray alloc] init];
UITabBar *topCentreTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 120, 75];
[topCentreItems addObject:viewSnapShotButton];
[topCentreItems addObject:fontButton];
topCentreTabBar.items = topCentreItems;

this is fairly straight forward if you look at the docs suggested by @Kyle the Unruly.

Here's an example of adding a built in button and your own image:

UIBarButtonItem * viewSnapShotButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(snapShotButtonPressed:)];
UIBarButtonItem * fontButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Font.png"] style:UIBarButtonItemStylePlain target:self action: @selector(fontSize:)];

// Add buttons to the tab bar
NSMutableArray *topCentreItems = [[NSMutableArray alloc] init];
UITabBar *topCentreTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 120, 75];
[topCentreItems addObject:viewSnapShotButton];
[topCentreItems addObject:fontButton];
topCentreTabBar.items = topCentreItems;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文