Positioning UITabBar at the top
Is it possible? Sure, but it violates the human interface guidelines.
Screenshots:
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
Finish All Asynchronous Requests Before Loading Data
Shift Elements in Array by Index
Xcode Is Looking for Core Data Entity Names with Dot; Not Compiling
Foreign Key Relationship Mapping with Restkit
How to Trap on Uiviewalertforunsatisfiableconstraints
Stop Uiwebview from "Bouncing" Vertically
Core Data Background Context Best Practice
Changing Navigation Bar Color in Swift
How to Dismiss Viewcontroller in Swift
Ios: What's the Fastest, Most Performant Way to Make a Screenshot Programmatically
In iPhone App How to Detect the Screen Resolution of the Device
Iphone: How to Get Current Milliseconds
How to Dismiss the Keyboard When Editing a Uitextfield
Passing Image to Another View Controller (Swift)
iOS 8 Enabled Device Not Receiving Push Notifications After Code Update