update readme file
Custom animated segmented control written in Swift 5.2
.package( url: "https://github.com/mednoor/MNSwitchi.git", from: "0.2.0" )
MNSwitchi
import MNSwitchi
You can initialize a MNSwitchi instance from code:
let switchiView = MNSwitchiView(frame: CGRect(x: 0, y: 0, width: 240, height: 36)) view.addSubview(switchiView)
switchiView.render( content: MNSwitchiContent, appearance: MNSwitchiAppearance, options: MNSwitchiOptions )
In order to set items you need to pass a tuple of type MNSwitchiContent:
MNSwitchiContent
let items: MNSwitchiContent = (first: "First", second: "Second")
In order to set the styling you need to pass an object of type MNSwitchiAppearance:
MNSwitchiAppearance
let appearance = MNSwitchiAppearance(backgroundColor: UIColor, cornersRounded: Bool, selectedViewBackgroundColor: UIColor, states: MNSwitchiStates)
then create an instance of MNSwitchiStates:
MNSwitchiStates
let states = MNSwitchiStates( default: MNSwitchiStates.MNSwitchiState(textColor: UIColor, titleFont: UIFont), selected: MNSwitchiStates.MNSwitchiState(textColor: UIColor, titleFont: UIFont), highlighted: MNSwitchiStates.MNSwitchiState(textColor: UIColor, titleFont: UIFont) )
MNSwitchi can be customized by passing an instance of MNSwitchiOptions:
MNSwitchiOptions
let options = MNSwitchiOptions(defaultSelectedItem: Int, enableAnimation: Bool)
switchiView.switchedTo = { index in print("Selected item at: \(index)") }
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
MNSwitchi
Custom animated segmented control written in Swift 5.2
Requirements
Installation
Swift Package Manager
Usage
Import
MNSwitchi
moduleInit
You can initialize a
MNSwitchi
instance from code:Setup
MNSwitchi
Configuring Content
In order to set items you need to pass a tuple of type
MNSwitchiContent
:Appearance
In order to set the styling you need to pass an object of type
MNSwitchiAppearance
:then create an instance of
MNSwitchiStates
:Customization
MNSwitchi
can be customized by passing an instance ofMNSwitchiOptions
:Handling callback