Giter Site home page Giter Site logo

rsexplodingbutton's Introduction

RSExplodingButton

A custom UIButton inspired by the "radial menu" that displays any number of subordinate buttons ("leaf buttons") when tapped and held.

RSExplodingButton Sample Animation

It's designed to be a drop-in replacement for UIButton, supporting UIControlEvent for user-interaction and UIControlState for controlling its changes in appearance. Thus it supports being used and configured from Interface-Builder as well as directly from code.

A simple interactive demo project is included.

Usage:

Initialization

Creating a button via code can be accomplished as follows:

RSExplodingButton *button = [RSExplodingButton alloc] initWithFrame:frame];
[self.view addSubview:button];

Adding leaf-buttons

Adding a leaf button is done through instance methods that duplicates the appearance of the root button. As with standard UIButton controls, a leaf button will require a method selector to be provided for responding to touch events:

for (int i = 0; i < numberOfButtonsDesired; i++)
{
    RSExplodingButton *button = [self.explodingButton addButtonWithTitle:[NSString stringWithFormat:@"%d", i+1]];
    [button addTarget:self action:@selector(didTouchUpButton:) forControlEvents:UIControlEventTouchUpInside];
}

Appearance

By default, the button assumes the tintColor property as the fill color for its highlighted state and the backgroundColor as the fill color for its normal state. When the button is highlighted, the colors inverse.

The button appearance can be customized in the following ways:

  • setDefaultColor: will update the background color of the button for UIControlStateNormal
  • setHighlightColor: will update the tint color for UIControlStateNormal and the background color for UIControlStateHighlighted

rsexplodingbutton's People

Contributors

rstrahl avatar

Stargazers

Jamie Birch avatar Aaron ttgb avatar Andy avatar Brad Cerasani avatar Jason Miller avatar

Watchers

 avatar

Forkers

shirakaba

rsexplodingbutton's Issues

Finalize look and animation of button

Button normal-state should be circular, non-filled. On touch-down button should fill with transparency. On touch-up button fill should fade ~ .5 sec ease out.

Consider lowering alpha of other non-selected children.

Add customizable angle for radial distribution

Currently the button is fixed to distribute buttons along a 360-degree path. Add logic that lets a dev specify the start angle and end angle for distribution. (e.g. - create a 90-degree distribution arc by specifying a start of 270 and end of 0, specifying clockwise orientation)

Add effect to indicate user has given button selected

No effect currently that indicates the user has a given button selected - as user moves finger from root to leaf, a visual indicator should be displayed. (Slightly larger button, different colour, ring around button, etc. pick one.)

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.