Positioning Uitabbar at the Top

Positioning UITabBar at the top

Is it possible? Sure, but it violates the human interface guidelines.

Screenshots:

Portrait Landscape Storyboard

Code:

TabController.h:

#import 

@interface TabController : UITabBarController

@end

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

How change UITab bar position to top?

I added image view for background in story board, That's why i'm getting this problem. I removed image view in storyboard and added background image through programmatically.

let imageView = UIImageView(image: UIImage(named: hdpi.png")!)
imageView.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)
view.insertSubview(imageView, at: 0)

Now my problem is solved...

Is there a way to change the text position in UITabBar or UITabBarItem?

Why don't you just have an empty title property for your view controller and add the title to your custom images for the tab?

UPDATE: For the sake of completeness of answer; from comments and ios tabbar put text in the middle when no image

[tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)]



Related Topics



Leave a reply



Submit