Giter Site home page Giter Site logo

wmsegmentcontrol's Introduction

WMSegmentControl

Custom segment control for iOS

Detail information with screen

https://elearningswift.com/custom-segment-control-for-ios-wmsegmentcontrol/

Usage

Using WMSegment control is easy

With Storybord

Drag a UIView and change its class to WMSegment.
now you can set the properties as per your requirements.

Programatically

let anotherSegment = WMSegment(frame: frame)
anotherSegment.type = .normal // normal (Default),imageOnTop, onlyImage
anotherSegment.selectorType = .bottomBar //normal (Default), bottomBar
// If you want round selector 
anotherSegment.isRounded = true //By default false
//Set titles of your segment
anotherSegment.buttonTitles = "Apple,Google,Facebook"
//Set images 
anotherSegment.buttonImages = "apple_light,google_light,facebook_light"
//Set selected images 
anotherSegment.buttonSelectedImages = "apple_dark,google_dark,facebook_dark"

// set text color for non - selected segment values
anotherSegment.textColor = .black
// set text color for selected segment value
anotherSegment.selectorTextColor = .orange
//set Color for selected segment
anotherSegment.selectorColor = .green
//set font for selcted segment value
anotherSegment.SelectedFont = UIFont(name: "ChalkboardSE-Bold", size: 15)!
// set font for segment options
anotherSegment.normalFont = UIFont(name: "ChalkboardSE-Regular", size: 15)!
self.view.addSubview(anotherSegment)

Get selected Index

you can get the selected index two ways
1. Using Callback (swifty way)
anotherSegment.onValueChanged = { index in
            print("I have selected index \(index) from WMSegment")
        }
 2. Using Function - connect with segment for valueChange event
 @IBAction func segmentValueChange(_ sender: WMSegment) {
        print("selected index = \(sender.selectedSegmentIndex)")
    }

Installation

Using CocoaPods

pod 'WMSegmentControl'

Manually

Copy WMSegment.swift file from source folder and add it to your project.

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.