Latest 1.2.5
Homepage https://github.com/uMina/XYXFlatSegmentControl
License MIT
Platforms ios 9.0, requires ARC
Authors

自定义的SegmentControl, 所有按钮通过titles属性自动添加, 均匀平铺在界面同一行上, 切记仅且只有有一行.
可自定义按钮颜色、字体大小、下划线厚度等.也可以自定义初始化时哪个按钮应该被选中.

bbb

支持Cocoapods

获取方法:
pod ‘XYXFlatSegmentControl’, ‘~> 1.2.4’

初始化: 支持xib, 也支持纯代码方式

let segmentControl = XYXFlatSegmentControl()
let segmentControl = XYXFlatSegmentControl(frame:<#frame#>)

接下来segmentControl所有的参数都是选填的,请根据需求设置(过于简单的不列出):

 segmentControl.titles 用于一次性设置所有按钮的名称. 按钮的大小是根据Gap来自动控制的
 segmentControl.delegate 实现后才能获知哪个按钮被点击了.
 segView.defaultSelectedIndex 可以用于设定初始被选中的按钮
 segmentControl.underlineShouldDisplay 用于是否显示下划线
 segmentControl.underlineWidthBoundToText 下划线宽度与文字等宽或者与按钮等宽
 segmentControl.buttonUnderlineGap 下划线与按钮或者文字之间的间隙

关于Gap:
aa
A: horizontalGap
B: verticalGap
C: buttonGap
D: buttonUnderlineGap

Latest podspec

{
    "name": "XYXFlatSegmentControl",
    "version": "1.2.5",
    "summary": "u4fbfu6377u5b9eu7528u7684SegmentControl.",
    "swift_version": "4.0",
    "description": "u53efu8bbeu5b9au4e0bu5212u7ebfu7684segmentControluff0cu53efu4ee5u6dfbu52a0u5230navigationBaru4e0auff0cu4e5fu53efu9002u914du5230u666eu901aUIViewu4e0au3002u53efu4ee5u4fbfu6377u7684u8bbeu5b9au662fu5426u5e26u4e0bu5212u7ebfuff0cu4e0bu5212u7ebfu539au5ea6uff0cu6309u94aeu989cu8272u548cu5b57u4f53u5927u5c0fu3002u53efu901au8fc7Gapu4fbfu6377u7684u5bf9SegmentControlu5e03u5c40u8fdbu884cu8c03u6574uff0cu8fd8u80fdu6307u5b9au521du59cbu5316u65f6u88abu9009u62e9u7684segment.",
    "homepage": "https://github.com/uMina/XYXFlatSegmentControl",
    "screenshots": "https://github.com/uMina/XYXFlatSegmentControl/blob/master/bbb.gif?raw=true",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Teresa": "[email protected]"
    },
    "social_media_url": "https://umina.github.io/",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/uMina/XYXFlatSegmentControl.git",
        "tag": "1.2.5"
    },
    "source_files": "XYXFlatSegmentControl/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This