uitabbaritem

Preventing a UITabBar from applying a gradient to its icon images

雨燕双飞 提交于 2019-11-26 23:51:17
When I make icons for a UITabBar, it applies a gradient to the images. I need to know how to prevent it from having this gradient. Apple added tab bar customization in iOS 5, and now this kind of stuff is trivial. Prior to this it was a huge hack, and not recommended. Here's how to do a completely custom tab bar: // custom icons UITabBarItem *item = [[UITabBarItem alloc] init]; item.title = @"foo"; // setting custom images prevents the OS from applying a tint color [item setFinishedSelectedImage:[UIImage imageNamed:@"tab1_active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab1

set up an action with a tab bar item - iphone

十年热恋 提交于 2019-11-26 23:24:07
问题 I don't no if this is possible, but this there a way to treat a tab bar item click like a regular button click(action)? Here's the reason: I have a tab bar in my application, and for most of the tab bar items, I don't change the screen upon a touch, but I do change the data displayed in the view. It seems that it would be going a bit overboard to use a TabBarAppDelegate for this...is there a better way? Thanks 回答1: The most straightforward way is the UITabBarDelegate. Sorry. Implement your

Moving UITabBarItem Image down?

戏子无情 提交于 2019-11-26 22:14:31
问题 Normally on each tab of a UITabBar you have a small image and a title naming the tab. The image is positioned/centred towards the top of the tab to accommodate the title underneath. My question is: if you want to have a tabBar with just an image and no title is there a way to move the image down so it centers better within the tab? I am using (see below) currently: [tabBarItem setFinishedSelectedImage:tabSelected withFinishedUnselectedImage:tabUnselected]; but would prefer to use to larger

Add a line as a selection indicator to a UITabbarItem in Swift

∥☆過路亽.° 提交于 2019-11-26 21:00:58
问题 I wanna use a thick line at the bottom of a UITabbarItems as a selection indicator. Due to the fact that the App must work on different phone sizes, I cannot use a image as selection indicator. That's why I think I have to use Swift to do this. (The line has to be 1/3 of page width). I tried to use UITabBarItem.appearance() but without success. 回答1: You can do it with add custom image, that will be created in your code, to selectionIndicatorImage on your UITabBar object. For example you can

Remove tab bar item text, show only image

青春壹個敷衍的年華 提交于 2019-11-26 18:47:55
问题 Simple question, how can I remove the tab bar item text and show only the image? I want the bar items to like in the instagram app: In the inspector in xcode 6 I remove the title and choose a @2x (50px) and a @3x (75px) image. However the image does not use the free space of the removed text. Any ideas how to achieve the same tab bar item image like in the instagram app? 回答1: You should play with imageInsets property of UITabBarItem . Here is sample code: let tabBarItem = UITabBarItem(title:

Increment tab bar badge w/ UIAlertAction swift?

不羁岁月 提交于 2019-11-26 16:57:16
问题 @IBAction func addToCart(sender: AnyObject) { let itemObjectTitle = itemObject.valueForKey("itemDescription") as! String let alertController = UIAlertController(title: "Add \(itemObjectTitle) to cart?", message: "", preferredStyle: .Alert) let yesAction = UIAlertAction(title: "Yes", style: UIAlertActionStyle.Default) { (action) in var tabArray = self.tabBarController?.tabBar.items as NSArray! var tabItem = tabArray.objectAtIndex(1) as! UITabBarItem let badgeValue = "1" if let x = badgeValue

ios 11 UITabBar UITabBarItem positioning issue

帅比萌擦擦* 提交于 2019-11-26 15:37:17
问题 I have built my app using new Xcode 9 beta for ios 11. I have found an issue with UITabBar where items are spread through the UITabBar and title is right aligned to the image. I have tried changing the code to get it to work but still not successful. ios 10+ ios 11 I could change the position of title using tabBarItem.titlePositionAdjustment But that is not my requirement as it should automatically come bellow the image itself. I tried setting tabbar.itemPositioning to

How can I change the text and icon colors for tabBarItems in iOS 7?

﹥>﹥吖頭↗ 提交于 2019-11-26 15:17:11
问题 How can I change the text and icon colors for UITabBar and UITabBarItems in iOS 7? The default gray text seems dim and hard to read for unselected tabbar items. 回答1: There are two things you need to do for this: 1) If you want to customize the TabBar itself, you need to set the barTintColor for the tabBarController: // this will generate a black tab bar tabBarController.tabBar.barTintColor = [UIColor blackColor]; // this will give selected icons and text your apps tint color tabBarController

Changing font size of tabbaritem

别来无恙 提交于 2019-11-26 12:43:50
问题 Is it possible to change the font size of tabs? 回答1: I recommend a better way: [yourTabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, [NSValue valueWithUIOffset:UIOffsetMake(0,0)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"Helvetica" size:18.0], UITextAttributeFont, nil] forState:UIControlStateNormal]; 回答2: for(UIViewController *tab in self.tabBarController.viewControllers) { [tab.tabBarItem

IOS 8 Tab Bar Item Background Colour

我的未来我决定 提交于 2019-11-26 10:59:02
问题 I\'ve been trying to find the solution to this for the last week, and I have had no luck after trying every possible solution I could find or think of. Every solution I found and have attempted has either not worked, or been outdated. I have 5 UITabBarItem \'s in a UITabBar placed within UITabBarController . I want to change the background color of the UITabBarItem when it is selected, and of course have it change back when the selected item changes. I am using Swift, and iOS SDK 8.3 in Xcode