uitabbaritem

Setting badge value in UITabBarItem in UIViewController

时光怂恿深爱的人放手 提交于 2019-11-28 09:12:37
I am adding UITabBarController to the window, and setting the viewControllers property of the UITabBarController to the array of ViewControllers. If i am setting the badge value inside the viewController then its working fine. self.tabBarItem.badgeValue = @"3"; But if i am setting the viewControllers property of the UITabBarController to the array of navigation controllers which is having view controller as the rootviewcontroller, then its not setting the badge value. Any suggestions ?? Thanks Yes, i got the answer. [[self navigationController] tabBarItem].badgeValue = @"3"; BabyPanda Or this:

How do you connect a tab bar item to an action?

别说谁变了你拦得住时间么 提交于 2019-11-28 07:43:38
问题 I have a UIView which has a UITabBar with 4 UITabBarItem components in it (all created from IB). I want my IBAction function called when someone clicks on the items in the tab bar. But I am unable to connect the tabbaritem to my action via IB... I control drag from the "received actions" but it does not allow me to connect that to the tabbaritem. Thanks Deshawn 回答1: It is not clear from your question if you also defined a UITabBarController. If you did not (as I assume, otherwise clicking on

To change the color of unselected UITabBar icon in iOS 7?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 06:54:11
I know this question has been asked earlier as well, but still i didn't get any solution searching the solution on internet. I referred the following posts: How can I change the text and icon colors for tabBarItems in iOS 7? Only able to change the selected icons color using tintColor . How to change the color of unselected tab bar items in iOS 7? In this they have written their own GozTabBar class inherited from UIView I want to changes the default gray color of UITabBar icon when its in unselected state. Any help would be highly appreciated. Thanks in advance. Inertiatic I'm assuming that

Is there a way to use a custom selected image for UITabBarItem?

蓝咒 提交于 2019-11-28 05:08:42
I like to have a custom selected image when a user selects an item on the tab bar, by default it selects as blue like but would like to have a green color instead. something like below any thoughts? Just found my solution. Basically, I subclassed UITabItem and set this in the navigation controller: -(void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; CustomTabBarItem *tabItem = [[CustomTabBarItem alloc] initWithTitle:@"Events" image:[UIImage imageNamed:@"tabIcon.png"] tag:0]; tabItem.customHighlightedImage=[UIImage imageNamed:@"tabIconSelected.png"]; self.tabBarItem = tabItem

Swift - How to change UITabBarItem badge font?

百般思念 提交于 2019-11-28 03:53:29
问题 I have a UITabBar . I set a value for tab bar items: tabBarItem3?.badgeValue = String(self.numberOfProducts) Now I want to change its font to a specific font. Then I used this code : tabBarItem3?.setBadgeTextAttributes([NSFontAttributeName: UIFont(name: "IRANSans", size: 14)], for: .normal) It doesn't work. What should I do? 回答1: Swift 3 UITabBarItem.appearance().setBadgeTextAttributes([NSFontAttributeName: UIFont(name: "IRANSans", size: 14)], for: .normal) UITabBarItem.appearance()

Remove tab bar item text, show only image

自古美人都是妖i 提交于 2019-11-28 02:52:20
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? You should play with imageInsets property of UITabBarItem . Here is sample code: let tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "more") tabBarItem.imageInsets = UIEdgeInsets(top: 9, left: 0, bottom: -9, right:

An unwanted line on Tab bar controller under ios7

爷,独闯天下 提交于 2019-11-28 01:47:07
问题 Under iOs7, and not earlier versions, I've a line who pass through my Tab Bar (shown with green arrow on example picture from the link below). I don't know where the problem come from. Any idea how to correct it ? Thank you very much. 回答1: I think you have to check the height of UITabBar in iOS 7. It is possible Apple has decreased the height of UITabBar, as per height of UITabBar you have to redesign your image for accurate result. 回答2: If you're referring to the couple of pixel shadow on

tabbar item image and selectedImage

自闭症网瘾萝莉.ら 提交于 2019-11-27 22:38:25
I have a tab bar controller (its a tab bar based application, so tab bar is on MainWindow.xib). In this xib, I have added 4 tab bar items and I have set the image of all tab bar item. Due to this, I am facing 2 issues: 1) The image is white-colored, but when I run the application, its showing all the images on tab bar item as gray colored. How can I make it look same as is in the original image. 2) I have a selected image, that I want to add on the tab bar item which is currently selected. How should I do this??? UPDATED AFTER NICK's CODE: Hey, in iOS 5, you will have to write following code

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

陌路散爱 提交于 2019-11-27 22:22:10
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. 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 create extension for UIImage class like this: extension UIImage { func createSelectionIndicator(color:

How to add small red dot in UITabBarItem

半腔热情 提交于 2019-11-27 20:06:25
问题 How to add red dot on the top right side of the UITabBarItem . I have searched a while and some guys said this can be done setting Badge Value of the UITabBarItem .But when I give it a try and set badge value to empty space " ",the red dot is somewhat big.How can I get a proper one?Big thanks. 回答1: If you want to avoid traversing subviews & potentially dangerous hacks in general, what I've done is set the badge's background colour to clear and used a styled bullet point to appear as a badge: