Alan Smith
Alan Smith

Reputation: 33

How do i get the scrolling bar with buttons?

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

Upvotes: 3

Views: 1782

Answers (3)

adrianokw
adrianokw

Reputation: 389

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.

Upvotes: 3

O-mkar
O-mkar

Reputation: 5658

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

Upvotes: 6

Duncan C
Duncan C

Reputation: 131418

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.

Upvotes: 2

Related Questions