Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JaleelNazir/MJMaterialSwitch
A Customizable Switch UI for iOS, Inspired from Google's Material Design in Swift
https://github.com/JaleelNazir/MJMaterialSwitch
android animation ios material material-design material-ui mjmaterialswitch ripple rippleview swift switch uicontrol uiswitch
Last synced: 7 days ago
JSON representation
A Customizable Switch UI for iOS, Inspired from Google's Material Design in Swift
- Host: GitHub
- URL: https://github.com/JaleelNazir/MJMaterialSwitch
- Owner: JaleelNazir
- License: mit
- Created: 2017-03-24T06:01:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T02:07:33.000Z (over 3 years ago)
- Last Synced: 2024-05-01T15:53:36.283Z (6 months ago)
- Topics: android, animation, ios, material, material-design, material-ui, mjmaterialswitch, ripple, rippleview, swift, switch, uicontrol, uiswitch
- Language: Swift
- Homepage:
- Size: 200 KB
- Stars: 69
- Watchers: 6
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-swift - MJMaterialSwitch - A Customizable Switch UI for iOS, Inspired from Google's Material Design. (Libs / UI)
- awesome-ios - MJMaterialSwitch - A Customizable Switch UI for iOS, Inspired from Google's Material Design in Swift. [•](https://raw.githubusercontent.com/JaleelNazir/MJMaterialSwitch/master/MJMaterialSwitch.png) (Content / Switch)
- awesome-swift - MJMaterialSwitch - A Customizable Switch UI for iOS, Inspired from Google's Material Design. (Libs / UI)
- awesome-cocoa - MJMaterialSwitch
- awesome-swift - MJMaterialSwitch - A Customizable Switch UI for iOS, Inspired from Google's Material Design in Swift ` 📝 2 months ago` (UI [🔝](#readme))
- awesome-swift - MJMaterialSwitch - A Customizable Switch UI for iOS, Inspired from Google's Material Design. (Libs / UI)
README
# MJMaterialSwitch
## Overview
`MJMaterialSwitch` is google's material design like switch UI with animation features.
This library has cool and sophisticated animations, ripple effect and bounce effect. Also, customizable properties can be tweaked behaviors and enhance your application UI cool.
With this library, you can easily implement material design switch to your app.
## Usage
The simplest setup by code:
```Swift
let xPos: CGFloat = (UIScreen.main.bounds.width / 2 ) - 22.5
let yPos: CGFloat = (UIScreen.main.bounds.height / 2 ) + 50.0
self.switch2 = MJMaterialSwitch(frame: CGRect(x: xPos , y: yPos, width: 64, height: 60))
self.switch2.addTarget(self, action: #selector(switchStateChanged(_:)), for: UIControl.Event.valueChanged)
self.switch2.tarckEdgeInset = UIEdgeInsets(top: 18, left: 0, bottom: 18, right: 0)
self.switch2.tag = 2
switch2.trackOnTintColor = UIColor.red.withAlphaComponent(0.6)
switch2.thumbOnTintColor = UIColor.red// Call update UI method in last.
switch2.updateUI()self.view.addSubview(self.switch2)
```This is the simplest and easiest initialization.
## Usage by xib and Storyboard
- Create `UIView` and set the `MJMaterialSwitch` class.
- Create `IBOutlet` to add `valueChanged` target for the click actions### Customize Behaviors
MJMaterialSwitch has many prateters to customize behaviors as you like.#### Style and size
```var thumbOnTintColor: UIColor!
var thumbOffTintColor: UIColor!var trackOnTintColor: UIColor!
var trackOffTintColor: UIColor!var thumbDisabledTintColor: UIColor!
var trackDisabledTintColor: UIColor!var isBounceEnabled: Bool = false
var isRippleEnabled: Bool = true
var rippleFillColor: UIColor = .gray
```## Author
Jaleel Nazir
Buy me coffe:
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/mjaleelnazir)## License
MJMaterialSwitch is available under the MIT license.