将UITabBar定位在顶部 [英] Positioning UITabBar at the top
本文介绍了将UITabBar定位在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是iOS开发的初学者。我的问题是:是否可以将UITabBar定位在顶部以及如何定位?
我无法将我的UITabBar放在视图的顶部。
I'm a beginner in iOS development. My question is: is it possible to position UITabBar at the top and how? I can't position my UITabBar at the top of the view.
推荐答案
有可能吗?当然,但它违反了人机界面指南。
Is it possible? Sure, but it violates the human interface guidelines.
TabController .h:
TabController.h:
#import <UIKit/UIKit.h>
@interface TabController : UITabBarController <UITabBarControllerDelegate>
@end
TabController.m:
TabController.m:
#import "TabController.h"
@interface TabController ()
@end
@implementation TabController
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
[self.tabBar invalidateIntrinsicContentSize];
CGFloat tabSize = 44.0;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation))
{
tabSize = 32.0;
}
CGRect tabFrame = self.tabBar.frame;
tabFrame.size.height = tabSize;
tabFrame.origin.y = self.view.frame.origin.y;
self.tabBar.frame = tabFrame;
// Set the translucent property to NO then back to YES to
// force the UITabBar to reblur, otherwise part of the
// new frame will be completely transparent if we rotate
// from a landscape orientation to a portrait orientation.
self.tabBar.translucent = NO;
self.tabBar.translucent = YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
这篇关于将UITabBar定位在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文