Skip to content

onurhazar/OHSwitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OHSwitch

Fully Customizable UISwitch written in C#

Demo

Requirements

iOS 8.3+ Xcode 8.0+

How to Use

var frame = new CGRect(0, 0, 50, 26);
ohSwitch = new OHSwitch(frame)
{
    ThumbOffFillColor = UIColor.Gray,
    ThumbOnFillColor = UIColor.White,
    TrackOffFillColor = UIColor.Red,
    TrackOnFillColor = UIColor.Green
};
View.AddSubview(ohSwitch);

//Add event handler
ohSwitch.AddTarget(OnSwitchChanged, UIControlEvent.ValueChanged);

//Event handler
private void OnSwitchChanged(object sender, EventArgs e)
{
    Debug.WriteLine("Switch value is changed");
}

//Check switch status
if (ohSwitch.On)
{
    Debug.WriteLine("Switch is on, do something here");
}

//Set switch status On/Off, w/ or w/o Animation
ohSwitch.SetOn(true, true);

About

Customizable UISwitch written in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages