资源算法Magnetic

Magnetic

2020-01-07 | |  46 |   0 |   0

Magnetic

Build StatusLanguageVersionLicensePlatformCarthage compatible

Magnetic is a customizable bubble picker like the Apple Music genre selection.

Demo GIF

Demo Video

$ pod try Magnetic

Features

  • Adding/Removing Nodes

  • Selection/Deselection/Removed Animations

  • Multiple Selection

  • Images

  • Multiline Label

  • Documentation

Requirements

  • iOS 9.0+

  • Xcode 9.0+

  • Swift 5 (Magnetic 3.x), Swift 4 (Magnetic 2.x), Swift 3 (Magnetic 1.x)

Usage

A Magnetic object is an SKScene.

To display, you present it from an SKView object.

import Magneticclass ViewController: UIViewController {    var magnetic: Magnetic?
    
    override func loadView() {        super.loadView()        
        let magneticView = MagneticView(frame: self.view.bounds)
        magnetic = magneticView.magnetic
        self.view.addSubview(magneticView)
    }

}

Properties

var magneticDelegate: MagneticDelegate? // magnetic delegatevar allowsMultipleSelection: Bool // controls whether you can select multiple nodes. defaults to truevar selectedChildren: [Node] // returns selected chidren

Nodes

A Node object is a SKShapeNode subclass.

Interaction

// add circular nodelet node = Node(text: "Italy", image: UIImage(named: "italy"), color: .red, radius: 30)
magnetic.addChild(node)// add custom nodelet node = Node(text: "France", image: UIImage(named: "france"), color: .blue, path: path, marginScale: 1.1)
magnetic.addChild(node)// remove nodenode.removeFromParent()

Properties

var text: String? // node textvar image: UIImage? // node imagevar color: UIColor // node color

Animations

override func selectedAnimation() {    // override selected animation}override func deselectedAnimation() {    // override deselected animation}override func removedAnimation(completion: @escaping () -> Void) {    // override removed animation}

Delegation

The MagneticDelegate protocol provides a number of functions for observing the current state of nodes.

func magnetic(_ magnetic: Magnetic, didSelect node: Node) {    // handle node selection}func magnetic(_ magnetic: Magnetic, didDeselect node: Node) {    // handle node deselection}

Customization

Subclass the Node for customization.

For example, a node with an image by default:

class ImageNode: Node {    override var image: UIImage? {        didSet {
            texture = image.map { SKTexture(image: $0) }
        }
    }    override func selectedAnimation() {}    override func deselectedAnimation() {}
}

Installation

CocoaPods

To install with CocoaPods, simply add this in your Podfile:

use_frameworks!
pod "Magnetic"

Carthage

To install with Carthage, simply add this in your Cartfile:

github "efremidze/Magnetic"

Mentions

Communication

  • If you found a bug, open an issue.

  • If you have a feature request, open an issue.

  • If you want to contribute, submit a pull request.

Credits

https://github.com/igalata/Bubble-Picker

License

Magnetic is available under the MIT license. See the LICENSE file for more info.


上一篇:magnetissimo

下一篇:sQucumber-redshift

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...