简体   繁体   English

Objective-C标签视图控制器将标签栏移到顶部

[英]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.

相关问题 在Objective-C中为顶部标签栏添加菜单或按钮 - adding menue or buttons for Top Tab bar in objective-C 双击自定义选项卡栏,滚动到视图顶部:Objective-C - Scroll to top of view on second click of custom tab bar: Objective-C 如何在Tab栏控制器中使用一个Xib并创建多个视图控制器? [Objective-C] - How to use one Xib and create multiple view controllers in Tab bar controller ? [Objective-C] 在Objective-C中单击视图中的按钮后,如何按下标签栏控制器? - How can I push tab bar controller after click a button from a view in Objective-C? 从视图控制器移动到标签栏控制器 - Move from view controller to tab bar controller 移至其他视图控制器时的标签栏 - Tab bar when move to other view controller iOS /目标C。 离开View Controller之前检测选项卡栏上的选项卡按下 - IOS/Objective-C. Detect Press of Tab on Tab Bar Before Leaving View Controller 在Objective-c中以编程方式将底部栏设置为选项卡栏 - Setting the bottom bar as a tab bar programmatically in Objective-c 目标C:如何将红色标签添加到标签栏控制器 - Objective C: How to add a red color tab to a tab bar controller Objective-C 如何从与当前视图重叠的标签栏中显示操作表? - Objective-C how to present an action sheet from tab bar that overlaps the current view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM