欢迎光临
我们一直在努力

自定义SegmentControl,动态调节宽度、滚动位置,红点

建站超值云服务器,限时71元/月

自定义SegmentControl,动态调节宽度、滚动位置,红点

项目介绍:

JTSegmentControl

自定义SegmentControl,可以选择红点、动态调节segment宽度,以及滚动。

Display


Usage

Simple init JTSegmentControl

        var frame = CGRect(x: 10.0, y: 130.0, width: self.view.bounds.size.width - 20.0, height: 44.0)
        let segmentControl = JTSegmentControl(frame: frame)
        segmentControl.delegate = self
        segmentControl.items = ["first", "second", "third", "fouth"]
        segmentControl.showBridge(show: true, index: 1)
        segmentControl.autoScrollWhenIndexChange = false
        view.addSubview(segmentControl)
Width is divide equally . This is have bridge and not scrolling when index changed.(宽度根据bounds进行平分,展示红点,选择item的时候不自动调整位置)

Init JTSegmentControl,auto to set itemView’s width in scrollView, scrolling when index changed.(在一个ScrollView里,根据内容自动调整每个item的宽度,同时,选择item的时候自动调整它的位置。)

        frame = CGRect(x: 10.0, y: 250.0, width: self.view.bounds.size.width - 20.0, height: 44.0)
        let autoWidthControl = JTSegmentControl(frame: frame)
        autoWidthControl.delegate = self
        autoWidthControl.items = ["first", "second", "third", "fouth", "fifth", "sixth", "seventh", "eighth"]
        autoWidthControl.selectedIndex = 1
        autoWidthControl.autoAdjustWidth = true
        autoWidthControl.bounces = true
        view.addSubview(autoWidthControl)
JTSegmentControl Delegate
func didSelected(segement: JTSegmentControl, index: Int)

Also you can custom

    // JTSegmentPattern.swift
    static let itemTextColor
    static let itemSelectedTextColor
  
    static let itemBackgroundColor
    static let itemSelectedBackgroundColor
  
    //MARK - Text font
    static let textFont
    static let selectedTextFont
    
    //MARK - slider
    static let sliderColor
    static let sliderHeight
    
    //MARK - bridge
    static let bridgeColor

Author

JT. Guangzhou_xia

License

JTSegmentControl is Available under the MIT license.

求鼓励和意见:https://github.com/guangzhouxia/JTSegmentControl

code4app

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 自定义SegmentControl,动态调节宽度、滚动位置,红点
分享到: 更多 (0)