MJMaterialSwitch
  • December 1, 2023

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:

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

GitHub


View Github

#animation #anroid #ios #material #materialdesign #materialui #mjmaterialswitch #ripple #rippleview #swift #switch #uicontrol #uiswitch
YOU MIGHT ALSO LIKE...
exyte

     

camerakit-ios

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service ...

HybridCamera

[video width="192" height="416" mp4="https://swiftgit.com/wp-content/uploads/2024/12/68747470733a2f2f7261776769742e636f6d2f7374796c656b69742f696d672f6d61737465722f7669645f6564697465645f325f326d622e676966.mp4"][/video]

TakeASelfie

An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front ...

iOS-Depth-Sampler

Code examples of Depth APIs in iOS