Monday 24 November 2014

Jogendra Singh

UISwitch example in swift ios8

How to make UISwitch button in swift language ?

   UISwitch button is return a boolean value like : - true , false , yes , no etc.  In this tutorial we're going to learn example of UISwitch button in swift language, 

Open Object and create new project for UISwitch button .  name of project is "UISwitchExampleSwift" and select language is SWIFT.

Now go in Main.storyboard and drag and drop UISwitch button and One UILabel for showing current state of UISwitch button . 

Now Make object of both UISwitch button and UILabel or also make action of UISwitch Like this :- 

           var switchBtnObj : UISwitch!

 var stateLabelObj : UILabel

and Action of UISwitch button :-

 @IBAction func switchBtnClicked   (switchBtn : UISwitch ){

Connect both of in Storyboard like this :-

Now need to check in Action using if condition like this :- 

    @IBAction func switchBtnClicked   (switchBtn : UISwitch ){
        if switchBtn.on{
            stateLabelObj.text = "Switch btn is on now"
            stateLabelObj.text = "Switch btn is off now"

And change in display :-   If button is off 

Check if Button is On

Thanks for Visit  , Also can visit on My blog Facebook page iPhone & iPad Application Development Help World and also can visit Google+ 

Jogendra Singh

About Jogendra Singh -

I'm Founder of Jogendra.Com. I love to share my bright ideas with the whole blogging community. I'm a good iPhone Application Developer. Apart from Blogging, I love to play Cricket and mobile games (Clash of clans).

Subscribe to this Blog via Email :