Giter Site home page Giter Site logo

nick-icars / draurabutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from derunco/draurabutton

0.0 1.0 0.0 1.91 MB

A UIKit component featuring a UIButton surrounded by a circle. Originally created to CABasicAnimation experiment.

License: MIT License

Ruby 9.12% Objective-C 90.88%

draurabutton's Introduction

DRAuraButton

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

DRAuraButton is available through a non official CocoaPods repository. To install it, simply add the following lines to your Podfile:

source 'https://github.com/DeRunco/cocoapods/'
pod "DRAuraButton"

About

Animated transition from a configuration to another

DRAuraButton is a UIButton with a subview that displays a rotating circle. Multiple configuration of stroke width, radius, color and speed can be specified. Going from one configuration to another is animated.

This project was done mainly as a first approch to Core Animation framework -- it uses CABasicAnimations to animates transition between states.

Instantiate

Any storyboard button can be set to be a DRAuraButton.

States

The button presents arbitrary states, defined by the developer.

A state is defined by a set of properties, stored in a DRAuraConfiguration object. Among those properties are the ID. It serves as state identifier (see DRAuraButton.currentStateID). All states must have a unique ID.

To create and add a new state, use DRAuraButton addAuraConfiguration: method:

[myButton addAuraConfiguration:^(DRAuraConfiguration *c) {
	c.ID = @"my State name";
	c.width = 2.;
	c.space = 7.;
	c.offset = 6.;
	c.step = 0.04;
	c.animationDuration = 0.3;
	c.auraColor = [UIColor blackColor];
	c.buttonColor = [UIColor grayColor];
}];

To switch to that state, call setCurrentStateID: :

[myButton setCurrentStateID:@"my State name"];

To remove a state from the object, call removeAuraConfiguration: :

[myButton removeAuraConfiguration:@"my State name"];

Customizable properties

  • Angle of rotation per frame: set DRAuraConfiguration.step. Greater is faster. Rotation is animated by NSTimer each 0.016s. As per NSTimer however, this time interval is not guaranteed.
  • Space between the button and the circle: set DRAuraConfiguration.space. Greater is bigger
  • Space between the top half and the bottom half: set DRAuraConfiguration.offset. This value is half the actual arc length between each arc.
  • Stroke width: set DRAuraConfiguration.width. Greater is wider.
  • Color of the stroke: set DRAuraConfiguration.auraColor.
  • Color of the button's background layer: set DRAuraConfiguration.buttonColor.

License

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

draurabutton's People

Contributors

charlesthierry avatar nick-icars avatar

Watchers

James Cloos 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.