Git Product home page Git Product logo

apolymorphic-button's Introduction

Polymorphic-UIButton

A rectangular UIButton that transform itself into a circle (animated), with a built-in Activity indicator. Written entirely in Swift.

A short youtube Demo of the component

Table Of contents

Try It

Download/Clone the project. Open it with Xcode. Go in the Main.Storyboard File Select a Button. Now you can play/custom it with the attributes Inspector. Image Then Just Launch It (On simulator Or Device).

Installation

  1. Drop the LMPolymorphicButton.swift into your project
  2. There is no step Two.

Features

  • Highly and easily customizable
  • Built with and for Autolayout
  • Made with love

Requirements

  • Needs AutoLayout.

How to use

I will present here a simple usage case From Storyboard/Inteface builder. there is a lot of way to use this component. 1 Create a UIView 2 Inside that UIView Put a UIButton with these constraints:

  • Same Width (priority 750)
  • Same Height (priority 750)
  • Center Vertically
  • Center Horizontally 3 Change the Class of that UIButton to LMPolymorphicButton In the identity Inspector

That's It.

Now from the code you can just call the startActivity Method:

myAwesomeButton.startActivity()

myAwesomeButton.stopActivity()

How it works

LMPolymorphicButton Uses Autolayout's.

There are two animations, the CornerRadius Animation (To transform it into a Circle) and the AspectRatio Constraint’s Animation (to set the width equal to the height, circle/square). LMPolymorphic add programttically a constraints to Itself: AspectRatio 1:1. When I Need to collapse It I change the priority Of this constraint to 800(this value must be greater than the « Same Width » and « Same Height » priority. And when I need to expand it I change the priority from 800 to 200. I Just Animate this priority Change.

The CornerRadius Animation is a simple CABasicAnimation.

So LMPOlymorphicButton Requires AutoLayout To works.

Fully Customizable From Storyboard.

Misc

Pull requests are welcome Just Open an Issue Or Make A pull Request to add It here.

Needs Help?

Just open an Issue.

apolymorphic-button's People

Contributors

lastmove avatar

Stargazers

ChrisyehGone avatar

Watchers

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