MHTabView 1.4.0

MHTabView 1.4.0

Maintained by feaskters.



MHTabView 1.4.0

  • By
  • ZhangMingHao

MHTabView

CI Status Version License Platform

  • An easy way to use scroll tab bar
  • If MHTabView helps you, please give her a star, thanks!

Contents

Installation

MHTabView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MHTabView'

Getting Started

usage

There are two ways to create your own tabview

  1. convenience init
let tabview = MHTabView.init(withTitles: titles, pageViews: views)
  1. init and set titles and pageviews
let tabview = MHTabView.init()
tabview.setTitlesAndPageViews(titles: titles, pageViews: views)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

  • unscrollable

tabview.titleStyle = .unscrollable

unscrollable

  • scrollable

tabview.titleStyle = .scrollable

scrollable

  • autoscrollable

tabview.titleStyle = .autoScrollable

autoscrollable

  • autoUnscrollable

tabview.titleStyle = .autoUnscrollable

autoUnscrollable

  • other

  1. change color
tabview.defaultColor = .blue
tabview.selectedColor = .red
tabview.indicatorView.backgroundColor = .green
  1. change width for scrollable style
tabview.style = .scrollable
tabview.tabWidth = 150
  1. usage of delegate
protocol MHTabViewDelegate {
  /**停止滚动后的回调函数(index, scrollview) -> (当前滚动到的位置, scrollView属性 )*/
  func MHTabViewDidEndDecelerating(_ index: Int, _ scrollview: UIScrollView)
}

delegate

  1. other APIs
setSelectedFont(_ font: UIFont)// 修改选中按钮的字体

setUnSelectedFont(_ font: UIFont)// 修改未选中按钮的字体

setIndicatorHeight(_ height: CGFloat)// 修改指示器高度

setIndicatorWidth(_ width: CGFloat)// 修改指示器宽度
 
setDefaultPage(withIndex index: Int)// 设置默认选中的页面

setAnimateDuration(_ duration: TimeInterval)// 设置动画过渡时间

setSelectedPage(withIndex index: Int)// 设置选中页面

modifyTitle(withIndex index: Int, newTitle: String)// 修改指定标题

setTitleHeight(_ height: CGFloat)//修改标题高度

Author

ZhangMingHao, [email protected]

License

MHTabView is available under the MIT license. See the LICENSE file for more info.