3

So first thing i have a news app so it has different category like business,national,state news and etc so i need a scrolling bar with button like this shown in the below image.

Bar with Buttons

i don't know what it is called tabbar, bar with buttons or there is something else storyboard.

i have searched every where one google but could not found it because i don't know what it is called

Till now i have try creating a vertical scrollview and adding buttons to it but if is not upto my staisfaction i want something better.. if you find any GitHub projects it will be good.

i even tried segmented control but it doesn't hold more category it becomes smaller and smaller so i want something like shown in the top image.

UPDATED

On click of any button i want to refresh the table view with the content of of category ...

Tab bar wont work

Thank You for your help in advance

Alan Smith
  • 33
  • 6
  • 1
    You might take a peek at this for ideas. https://www.cocoacontrols.com/controls/carbonkit-swift – Adrian Dec 24 '15 at 16:26
  • 1
    @AdrianB thanks but i want to refresh the table view and can i know what it is called ? so i can search google? – Alan Smith Dec 24 '15 at 16:31

3 Answers3

6

Your answer was already given in the comment by Adrian B..

i ill explain you how you have to do it. first of all it is called Tab Swipe navigation

Make use of Carbon kit

https://github.com/melieskubrick/CarbonKitSwift

So first add the elements to your view. this is the way how you add using Carbon Kit

override func viewDidLoad() {
    super.viewDidLoad()

    self.title = "CarbonKit"
    items = [UIImage(named: "home")!, UIImage(named: "hourglass")!, UIImage(named: "premium_badge")!, "Categories", "Top Free", "Top New Free", "Top Paid", "Top New Paid"]
    carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: items as [AnyObject], delegate: self)
    carbonTabSwipeNavigation.insertIntoRootViewController(self)
    self.style()

}

You want to refresh your news so using delegate method of Carbon Kit which is CarbonTabSwipeNavigationDelegate you can refresh your tableview.

 func carbonTabSwipeNavigation(carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAtIndex index: UInt) -> UIViewController {

        switch index {
        case 0:
            //Do your table view refresh here Business category 
        case 1:
           //Do your table view  refresh here other category 

        default:
            //Do your table view  refresh here all category  which will be default

        }

    }

Credit

Community
  • 1
  • 1
O-mkar
  • 5,430
  • 8
  • 37
  • 61
3

Based on your update, I think you can only use a HMSegmentedControl and change the content on your table view accordingly. HMSegmentedControl has an indexChangeBlock property where you can pass a block that will be called when another tab is selected.

adrianokw
  • 387
  • 3
  • 10
  • tabbar controller won't work i don't want to change the view controller – Alan Smith Dec 24 '15 at 16:58
  • oh great but its in objective c i cant understand how to use it.. thanks for your help – Alan Smith Dec 24 '15 at 17:06
  • @AlanSmith If you're using CocoaPods, just add this to your Podfile: "pod 'HMSegmentedControl'" and use "import HMSegmentedControl" in the file you want to use it. – adrianokw Dec 24 '15 at 17:11
2

The image you've linked is almost certainly a custom control.

It looks a bit like a UITabBar in a UITabBarController, but it isn't a tab bar controller.

If I was doing this I'd probably use the parent/child view controller support built into view controllers and create a custom parent view controller that implemented this functionality.

The control itself would not be hard. I'd create a custom control that contained multiple labels who's color changed based on the selected item, and a colored bar that I would animate to slide to the current selection.

The parent view controller would own the tab control. The tab control would fire an action on the parent view controller when the selected tab changed, and the parent view controller would swap in a new child view controller.

I also did some searching with the search string "custom UITabBar" and found this link:

Really cool way to create custom UITabBar for iPhone app?

It sounds like iDevReceipes may have a ready-made solution.

Community
  • 1
  • 1
Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • in point of tab bar you're right but tab bar will change the view controller or add a subview but i just need to refresh the table view with new content. Thanks for your help – Alan Smith Dec 24 '15 at 16:37
  • Oh! That's simpler then. Just build a custom subclass of UIControl that acts like a segemented control and sends an IBAction message on valueChanged. It's not that hard. – Duncan C Dec 24 '15 at 17:16