[英]Objective-C Tab view controller move tab bar to top
I create a tabviewcontroller in story board, I'm using Objective-C. 我在故事板上创建一个tabviewcontroller,使用的是Objective-C。
How can I move the position of the tab bar to the top? 如何将标签栏的位置移到顶部?
I found this code in swift how can it write it in Objective-C? 我很快找到了此代码,如何在Objective-C中编写它?
okay! 好的! cool.
凉。
Are you experienced in swift? 您是否经验丰富?
do you know how can i write this in Objective-C? 您知道我该如何在Objective-C中编写此代码吗?
Swift3: I achieve this by creating a custom class for UITabBarController: Swift3:我通过为UITabBarController创建一个自定义类来实现此目的:
class CustomTabBarController: UITabBarController {
@IBOutlet weak var financialTabBar: UITabBar!
override func viewDidLoad() {
super.viewDidLoad()
// I've added this line to viewDidLoad
UIApplication.shared.statusBarFrame.size.height
financialTabBar.frame = CGRect(x: 0, y:
financialTabBar.frame.size.height, width:
financialTabBar.frame.size.width, height:
financialTabBar.frame.size.height)
}
There's no supported way to do that with UITabBarController
. UITabBarController
没有支持的方法。
If you want a tab bar at the top of the screen, you'd have to build this yourself, or use an open source implementation. 如果要在屏幕顶部显示一个标签栏,则必须自己构建它,或者使用开源实现。
You may find something here but there are other implementations (on GitHub etc.). 您可能会在这里找到一些东西,但是还有其他实现(在GitHub等上)。
Having the tab bar at the top is an Android thing. 将标签栏放在顶部是Android的事情。 On iOS it's always been at the bottom.
在iOS上,它始终位于最底部。
It's important to consider that all important apps (including those from Apple) have the tab bar at the bottom. 重要的是要考虑到所有重要的应用程序(包括Apple的那些应用程序)的底部都具有选项卡栏。 Putting it at the top would mean that your app immediately feels weird for iOS users.
将其放在顶部将意味着您的应用对于iOS用户立即感到很奇怪。
If you are satisfied with your swift version then below is the translated objective-c code: 如果您对快速版本感到满意,那么下面是经过翻译的objective-c代码:
- (void)viewDidLoad{
[super viewDidLoad];
self.tabBar.frame = CGRectMake( 0, [UIApplication sharedApplication].statusBarFrame.size.height, self.tabBar.frame.size.width, self.tabBar.frame.size.height);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.