Giter Club home page Giter Club logo

buttonwheel's Introduction

ButtonWheel

ButtonWheel lets you create a circular collection of buttons. It's recommended for use whenever an app would want to give a lot of options or centralized navigation with a sleek, modern look. It allows for customization on images and labels for the buttons as well as more basic attributes like color, dimension, and shape.

You can import it into your project by putting this into your podfile:

pod 'ButtonWheel'

Use

After importing it into your project by putting pod 'ButtonWheel' in your podfile under frameworks and entering pod install into the command line. You can use ButtonWheel in any file by writing import ButtonWheel in that file.

ButtonWheel

init?(coder aDecoder: NSCoder) or override init(frame: CGRect)

ButtonWheel inherits from UIView. It can be instantiated either in storyboard or programmatically with the methods above from its superclass.

If you do instantiate it using an IBOutlet to storyboard, be sure to set both the class and the module in storyboard like this.

func setupWith(buttonPieces : [ButtonPiece], middleRadius : MiddleRadiusSize)

A setup function that must be called after initialization to build the view according to how it should look. The middleRadius parameter controls how big the hole in the middle of the wheel will be. MiddleRadiusSize is an enum with the cases .small, .medium, and .large. buttonPieces takes in an array of ButtonPiece which is a type that we will use to construct each section of the ButtonWheel.

ButtonWheelDelegate

func didTapButtonWheelAtName(name : String)

This is the function that will be called in the ButtonWheel's delegate to handle the buttons being pressed. The parameter passed into the function will be the name that you assigned to the tapped button.

ButtonPiece

init(name : String, color : UIColor, centerOffset : CGPoint)

Each ButtonPiece must be given a name, which will correspond to the label if you decide to add one using setLabel(...). The name will also match the name that is passed into didTapButtonWheelAtName(name : String) when it is called in the ButtonWheel's delegate. The color parameter is going to be the background color for the button, and centerOffset will allow the user to move the image and label from its default position on the ButtonPiece.

func setImage(image: UIImage, imageViewSize : CGSize, tintColor : UIColor?)

This sets an image, which will appear on the ButtonPiece when the ButtonWheel is set up with that piece. The parameters correspond respectively to the image itself, the size you want to set for it, and the tint color for the image. If you don't want to have a tint color, you can set this parameter to nil. Calling this after setLabel(...) won't replace the label, instead it will add the image along with the label.

func setLabel(maxLabelWidth : CGFloat, labelFont : UIFont, textColor : UIColor)

This sets a label, which will appear on the ButtonPiece when the ButtonWheel is set up with that piece. The parameters respectively correspond to the maximum width the label should have, the font for the label, and the label's text color. Calling this after setImage(...) won't replace the image, instead it will add the label along with the image.

buttonwheel's People

Contributors

kysomers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.