GithubHelp home page GithubHelp logo

jtsegmentcontrol's Introduction

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.

jtsegmentcontrol's People

Contributors

jizhidexia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.