Giter VIP home page Giter VIP logo

customsegmentedcontrol's Introduction

CustomSegmentedControl

CustomSegmentedControl - Customizable UISegmentedControl for iOS

A customized UIView subclass that customizes the design of UISegmentedControl UI element.

Demo image

Compatibility

  • iOS 12+
  • Xcode 10.0+
  • Swift 5.0

You can also use storyboard to create a CustomSegmentedControl UI element.

Features

  • Extremely simple and easy to use
  • Customizable interface

How to use

class ViewController: UIViewController, CustomSegmentedControlDelegate {

}

In order to customize CustomSegmentedControl when set from interface builder, use

@IBOutlet weak var interfaceSegmented: CustomSegmentedControl! {
    didSet{
        interfaceSegmented.setButtonTitles(buttonTitles: ["OFF","HTTP","AUTO"])
        interfaceSegmented.selectorViewColor = .orange
        interfaceSegmented.selectorTextColor = .orange
    }
}

Use the following code when CustomSegmentedControl is added programmatically.

    let codeSegmented = CustomSegmentedControl(frame: CGRect(x: 0, y: 50, width: self.view.frame.width, height: 50), buttonTitle: ["OFF","HTTP","AUTO"])
    codeSegmented.backgroundColor = .clear
    view.addSubview(codeSegmented)        

Implement CustomSegmentedControlDelegate protocol in order to perform custom action when the segmented control index is changed

    func change(to index:Int) {
        print("segmentedControl index changed to \(index)")
    }

Author

Github: @faganello60

License

The MIT License (MIT)

Copyright (c) 2018 Faganello.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

customsegmentedcontrol's People

Contributors

faganello60 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

customsegmentedcontrol's Issues

How to set default index?

Hi, I want to set second view as a default selected view, can you help me for how to achieve that feature.

Multiple times segment usage in different screen, btn == sender comparison not return true.

Hi, I use this custom segmented control in my project on different screens. First screen okey it works but when I go to second screen, my other custom segmented control won't work. I debug "if btn == sender" condition and i see btn and sender have same title but not have same address. Its mean buttons are same but not equal because they are different objects in memory. Why am I having such a problem like this. Any idea?

Change method is not calling even in your example also

Change method is not calling even in your example also.... i have been added added delegate in view controller class also but change method is not call. please help as soon as possible... my class delegation is like that

class WifiWatchViewController: UIViewController, CustomSegmentedControlDelegate {

func change(to index:Int) {
print("segmentedControl index changed to (index)")
}
}

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.