uitabbar

Change UITabBar selectedItem in Swift

风格不统一 提交于 2019-12-22 04:33:21
问题 How can I programmatically change the selected item in a UITabBar? 回答1: Swift 3 and later As of Swift 3, you can also use tabBarController.selectedIndex = 0 // (or any other existing index) (Thank you, @nidomiro.) Swift 2.2 and earlier Try the following tabBar.selectedItem = tabBar.items![newIndex] as! UITabBarItem Assuming you have access to the UITabBarController that owns the UITabBar , you can do the following self.selectedViewController = self.viewControllers![newIndex] as!

manually add UITabBar to UITableViewController

余生长醉 提交于 2019-12-21 21:56:13
问题 I have a standard app with a navigation controller managing several UITableViewController classes. I want to add a UITabBar to the root view (a UITableViewController) to manage filtering the selection of objects showin in the UITableView. I dont want/need a UITabBarController. The UITabBar is only for functionality and UI (radio-button style selection and familiar tabbar UI). I just want to manually create a UITabBar and add it to my view anchored/locked to the very bottom of the screen like

How to get a fully transparent TabBar in UITabBarController [duplicate]

余生颓废 提交于 2019-12-21 21:25:18
问题 This question already has an answer here : UITabBar fully transparent (1 answer) Closed 6 years ago . I have spent the last few hours trying to get the TabBar in a UITabBarController fully transparent (clear background). I use a custom subclass of the UITabBarController and I managed to change the tintColor, the alpha, but the background color definitely remains the one defined in IB. Thanks for your help, I'm getting crazy... 回答1: Here is one way to accomplish that. CGRect frame = CGRectMake

Configuring a UITabBar with more than 16 items

被刻印的时光 ゝ 提交于 2019-12-21 20:23:38
问题 My UITabBarController contains more than 16 view controllers. When I go in the "More" tab, I can see all the UITabBarItems . If I click the "Edit" button, I can see the 16 first icons, but there is not enough room to display more, so starting from the 17th item, the icons are only partially displayed. Starting from the 21st item, the icons are not displayed at all. And it is not possible to access the rest of the icons with a scroll bar. By the way, this question gives a theoretical answer to

UITabBarController: UITabBarItem Updating it or Reloading it

半世苍凉 提交于 2019-12-21 05:36:08
问题 How do I update or reload the text color on the UITabBarItem? It will, only if I kill the app and re-open again. Then it will refresh the textColor on the UITabBarItem Swift 5.1, iOS 12 func handleRefreshForTabBar() { DispatchQueue.main.async { //Background self.view.backgroundColor = Theme.current.generalBackground //Images self.tabBar.tintColor = Theme.current.tabTintColor //Bar self.tabBar.barTintColor = Theme.current.tabBarTintColor } } override func viewWillAppear(_ animated: Bool) {

Adding a UITabBar and tabbaritems to the UITabBar through code ( NOTE: I don't want to implement TabBarController )

余生颓废 提交于 2019-12-21 04:53:43
问题 I have searched a lot and beleive me i have come across many questions and sample codes but none of them fit my requirement , it's crazy how can there not be an answer for this. My requirements specifically:- 1. I want a UITabBar not a UITabBarController 2. I want it to be on the top-right corner of my UIView 3. I want two tab bar items on it( need not be assiciated with two view controllers) Now what i did was UITabBar *myTabBar=[UITabBar alloc]initWithFrame:myTabFrame]; [self.view

How to move title of UITabBarItem?

北慕城南 提交于 2019-12-21 03:45:29
问题 Can somebody tell me please how can I move title of UITabBarItem for example 2px to top? 回答1: Solution: UITabBarItem *item = [tabBar.items objectAtIndex:0]; item.titlePositionAdjustment = UIOffsetMake(0, -5.0); 回答2: Update for Swift 3 Put this code inside UITabBarController : UITabBarItem.appearance().titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -5) Credit goes to Tim Brown 回答3: Swift 4 Like me, if you are creating tab bar controller inside some other controller just after

iOS - Getting desired shadow above UITabBar

情到浓时终转凉″ 提交于 2019-12-21 03:32:46
问题 I am trying to get my tab bar shadow to look like the one seen in this image: What is the best way of doing this? I am using objective-c Thanks 回答1: You can give shadow by using following code to any UI object tabControl.layer.shadowOffset = CGSizeMake(0, 0); tabControl.layer.shadowRadius = 2; tabControl.layer.shadowColor = [UIColor blackColor].CGColor; tabControl.layer.shadowOpacity = 0.3; Here i gave example for your tabControl object. 回答2: For Swift 4 : self.tabBarController?.tabBar.layer

UITabBar appearance setSelectionIndicatorImage does not work on first launch iOS7

我们两清 提交于 2019-12-21 03:29:12
问题 I have a customised UITabBar and use the following code in the AppDelegate: - (void)tabBarController:(MainUITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { [self customizeTabBar]; } - (void)customizeTabBar { NSLog(@"*******customizeTabBar*******"); UIImage *tabBackground = [[UIImage imageNamed:@"unselectedtab"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; // Set background for all UITabBars [[UITabBar appearance]

Space between custom UITabBar and ViewController

别说谁变了你拦得住时间么 提交于 2019-12-21 02:35:12
问题 I took a regular UITabBar and changed it's background image to a custom one which has a lower height, so I changed the height of the frame . At first what I got is a blank space below the tab bar. so I changed the origin of the frame too. But now the blank space has moved up above the tab bar and this is the result: And this is the code declaring the tab bar in the AppDelegate: self.tabContoller = [[UITabBarController alloc] init]; //customizing the tabbar UIImage * tabBackgroundImage =