uitabbaritem

detect when a tabBar item is pressed via UITabBarController from App Delegate

我只是一个虾纸丫 提交于 2019-12-01 17:23:45
问题 I know this question has been asked a few times, but I am still stuck on the case when I have my UITabBarController in my AppDelegate class and viewControllers are set there only as self.tabBarController.viewControllers = @[aboutUsNavController,myProfileNavController, projectsListNavController, feedsNavController,homeViewController]; Now what I want is to perform a task at the tap of TabBar item feedsNavController not in viewWillAppear (because it is pushing a detailView via

UITabBarItem icon not colored correctly for iOS 13 when a bar tint color is specified in Interface Builder in Xcode 11, beta 2

烈酒焚心 提交于 2019-12-01 16:22:35
问题 I have a problem with the color of my UITabBarItems when I run on iOS 13 simulators, using Xcode 11, beta 2. I have made a sample project from scratch, and everything works correctly when I do not specify a bar tint color. However, when I do specify a custom bar tint color via Interface Builder, I get this: All items icons in the tab bar have the selected color if I set the "Bar Tint" property in Interface Builder to anything but clear. When it is set to clear, the icons are colored properly.

How to adjust tab bar badge position?

偶尔善良 提交于 2019-12-01 04:26:21
I'm displaying badge on tab bar but when number increase it goes out to tab bar item like shown in image I want to move the badge view slightly left so it fit on selected tab image.i tried as described here but no luck. So is there is any way to adjust badge view position?Any help would be appreciated. I found Kateryna's answer to be useful in putting me on the right track, but I had to update it a little: func repositionBadge(tab: Int){ for badgeView in self.tabBarController!.tabBar.subviews[tab].subviews { if NSStringFromClass(badgeView.classForCoder) == "_UIBadgeView" { badgeView.layer

How to change color for tab bar non selected icon in swift?

巧了我就是萌 提交于 2019-12-01 04:03:56
How to change color for tab bar non selected icon and text? I found this answer ( How to change inactive icon/text color on tab bar? ), but can't implement it for swift. iOS 10 class TabBarVC: UITabBarController { override func viewDidLoad() { super.viewDidLoad() // make unselected icons white self.tabBar.unselectedItemTintColor = UIColor.white } } BoilingLime The below sets the defaults for all UITabBarItem's, you can add it to your AppDelegate . It will change your text color. UITabBarItem.appearance().setTitleTextAttributes({NSForegroundColorAttributeName: UIColor.blackColor()}, forState:

Prevent tabbar from changing tab at specific index - IOS

不羁的心 提交于 2019-12-01 02:52:41
Thanks for reading my question. I'm trying to implement a popup menu when a user clicks the tab with the index of 4. So I'm trying to prevent the tabbar from switching viewcontroller when index 4 is pressed. Here is my code: - (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { if(viewController == [tabBarController.viewControllers objectAtIndex:4]){ NSLog(@"NO"); return NO; }else{ NSLog(@"YES"); return YES; } } I've implemented the UITabBarControllerDelegate and self.delegate = self; in the viewDidLoad and it works but

Change only one specific UITabBarItem tint color

♀尐吖头ヾ 提交于 2019-12-01 01:16:38
问题 It is well known that the tint color of selected (or active) items in a UITabBarController can be easily changed, here is an example: myBarController.tabBar.tintColor = [UIColor redColor]; In this instance, any tab bar item in tabBar will have a red tint once it is made active. Again, this applies to all of the items in this tab bar. How can the active tint color be different between other tab bar items in the same bar? For example, one item might have a red tint while selected, while another

Deselect or unselect all tabs in tabbar in iOS 5

怎甘沉沦 提交于 2019-11-30 21:23:42
I am new to iOS development and I have started with IOS 5 directly. I have created a storyboard which consists of a tabview controller as its rootviewcontroller. I have put 2 tabs to it. I want to deselect/unselect all the tabs initially. How do I do this? I have tried the following UIView *view = [[UIView alloc]initWithNibName:@"view" bundle:[NSBundle mainBundle]]; [self.tabBarController setSelectedViewController:nil]; [self.tabBarController setSelectedViewController:view]; where I have added a view with identifier "view". But this didn't work, it gives error: unrecognized selector sent to

Is it possible to remove the images in the UITabBarItem and aligned vertically the title

回眸只為那壹抹淺笑 提交于 2019-11-30 19:41:10
I have a UITabBar but i don't want to set the images I just want to set the title, and I want this title to be aligned vertically. Is this possible? Thanks Not that I know of. I think you'd need to create images of your text labels (either in advance in your graphic tool of choice, or you can create them programmatically at runtime). If you want to do it programmatically, a method like the following might do it. It creates a center-aligned image using the text you pass it, performing word-wrap. UITabBarItem *item = [self.tabBar.items objectAtIndex:0]; item.image = [self makeThumbnailFromText:@

How can I find the UIView for a specific UITabBarItem?

有些话、适合烂在心里 提交于 2019-11-30 18:30:38
I am using an external library called SwiftyWalkthrough, which allows me to expose only certain views on the screen to guide a new user through my app's UI. The first item I want exposed to the user is a UITabBarItem. I need to find the UIView associated with that specific UITabBarItem. I know the index for the item, and I have given it a tag. But I haven't found a way for them to help me find the view. Of course, I only want to use public interfaces to accomplish this. Carl Smith I solved my problem by accessing the subviews of the tabBar. The views with userInteractionEnabled are

ios tabbar put text in the middle when no image

梦想的初衷 提交于 2019-11-30 17:48:43
My tabbar consists only of text, no images. The problem is that the text always show on the bottom of the tab, is there a way to position the text in the middle ? Thank you Got it! [tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)] A supplement, if you set multi viewControllers in tabBarController, you should use the following: for (UITabBarItem* item in tabBarController.tabBar.items) { [item setTitlePositionAdjustment:UIOffsetMake(0, -10)]; } swift update. func tabBarItem(title: String, imageName: String, selectedImageName: String, tagIndex: Int) -> UITabBarItem { let item =