Giter Club home page Giter Club logo

ahkbendableview's Introduction

AHKBendableView

CocoaPods

BendableView is a UIView subclass that bends its edges when its position change is animated. Internally, BendableView contains CAShapeLayer, which acts as its background. The layer's path changes during animations, creating an effect of bending. Subviews stay intact. You can find a more extensive description on my blog: Recreating Skype's Action Sheet Animation and Follow-Up Post.

Demo GIF

Usage

BendableView contains three public properties:

var damping: CGFloat // set to animate the view's edges differently than the whole view (used in an internal spring animation)
var initialSpringVelocity: CGFloat // same as above
var fillColor: UIColor // "background" color of the bendable layer

You should set them before animating the position change of the view. I propose to use slightly lower values for damping and initialSpringVelocity than the values used when calling +animateWithDuration:delay:usingSpringWithDamping: initialSpringVelocity:options:animations:completion:, just like in this example:

let bv = BendableView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.addSubview(bv)

// bending setup
bv.fillColor = UIColor.redColor()
bv.damping = 0.7
bv.initialSpringVelocity = 0.8

UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.9, options: .BeginFromCurrentState | .AllowUserInteraction, animations: {
        bv.frame.origin = CGPoint(x: 200, y: 300)
        bv.frame.size = CGSize(width: 150, height: 150)
    }, completion: nil)

Have fun!

Example project

To run the example project, clone the repo, and open Example/AHKBendableView.xcodeproj.

Requirements

  • iOS 7.0
  • ARC

Installation

AHKBendableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AHKBendableView"

Author

Arkadiusz Holko:

ahkbendableview's People

Contributors

fastred avatar

Stargazers

 avatar

Watchers

 avatar  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.