如何获得带按钮的滚动条?

时间:2021-10-25 07:17:45

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.

所以首先我有一个新闻应用程序,所以它有不同的类别,如商业,国家,国家新闻等所以我需要一个滚动栏,按钮如下图所示。

如何获得带按钮的滚动条?

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

我不知道它叫什么tabbar,带按钮的栏或者还有其他的故事板。

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

我搜索过一个google但却找不到它的地方因为我不知道它叫什么

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.

直到现在我已经尝试创建一个垂直滚动视图并添加按钮,但如果不满足我的要求我想要更好的东西..如果你发现任何GitHub项目它会很好。

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

提前谢谢你的帮助

3 个解决方案

#1


6  

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

你的回答已经在Adrian B的评论中给出了..

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

我生病了解你如何做到这一点。首先它被称为Tab Swipe导航

Make use of Carbon kit

使用Carbon套件

https://github.com/melieskubrick/CarbonKitSwift

https://github.com/melieskubrick/CarbonKitSwift

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

首先,将元素添加到视图中。这是使用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.

您想刷新您的新闻,因此使用Carbon Kit的委托方法CarbonTabSwipeNavigationDelegate可以刷新您的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

信用

#2


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.

根据您的更新,我认为您只能使用HMSegmentedControl并相应地更改表视图中的内容。 HMSegmentedControl具有indexChangeBlock属性,您可以在其中传递将在选择另一个选项卡时调用的块。

#3


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.

它看起来有点像UITabBarController中的UITabBar,但它不是标签栏控制器。

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:

我也用搜索字符串“custom UITabBar”进行了一些搜索,发现此链接:

Really cool way to create custom UITabBar for iPhone app?

真的很酷的方式来为iPhone应用程序创建自定义UITabBar?

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

听起来iDevReceipes可能有一个现成的解决方案。

#1


6  

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

你的回答已经在Adrian B的评论中给出了..

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

我生病了解你如何做到这一点。首先它被称为Tab Swipe导航

Make use of Carbon kit

使用Carbon套件

https://github.com/melieskubrick/CarbonKitSwift

https://github.com/melieskubrick/CarbonKitSwift

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

首先,将元素添加到视图中。这是使用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.

您想刷新您的新闻,因此使用Carbon Kit的委托方法CarbonTabSwipeNavigationDelegate可以刷新您的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

信用

#2


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.

根据您的更新,我认为您只能使用HMSegmentedControl并相应地更改表视图中的内容。 HMSegmentedControl具有indexChangeBlock属性,您可以在其中传递将在选择另一个选项卡时调用的块。

#3


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.

它看起来有点像UITabBarController中的UITabBar,但它不是标签栏控制器。

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:

我也用搜索字符串“custom UITabBar”进行了一些搜索,发现此链接:

Really cool way to create custom UITabBar for iPhone app?

真的很酷的方式来为iPhone应用程序创建自定义UITabBar?

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

听起来iDevReceipes可能有一个现成的解决方案。