• Stars
    star
    592
  • Rank 75,570 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

UIView subclass that bends its edges when its position changes.

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:

More Repositories

1

Optimizing-Swift-Build-Times

Collection of advice on optimizing compile times of Swift projects.
Swift
3,579
star
2

MotionBlur

MotionBlur allows you to add motion blur effect to iOS animations.
Objective-C
1,505
star
3

AHKActionSheet

An alternative to the UIActionSheet inspired by the Spotify app.
Objective-C
1,162
star
4

IBAnalyzer

Find common xib and storyboard-related problems without running your app or writing unit tests.
Swift
955
star
5

SloppySwiper

UINavigationController delegate that allows swipe back gesture to be started from anywhere on the screen (not just from the edge).
Objective-C
806
star
6

DeallocationChecker

Catch leaking view controllers without opening Instruments.
Swift
793
star
7

EmojiTextView

Tap to swap out words with emojis. Inspired by Messages.app on iOS 10.
Swift
338
star
8

ReflectableEnum

Reflection for enumerations in Objective-C.
Objective-C
330
star
9

ConfigurableTableViewController

Typed, yet Flexible Table View Controller
Swift
269
star
10

AHKNavigationController

A UINavigationController subclass that re-enables the interactive pop gesture when the navigation bar is hidden or a custom back button is used.
Objective-C
232
star
11

HamburgerButton

Animated hamburger button.
Swift
197
star
12

BouncyView

Action Sheet animation based on Skype's iOS app.
Swift
128
star
13

AHKSlider

A UISlider subclass that improves the precision of selecting values.
Objective-C
59
star
14

SwiftOutTimingFunction

SwiftOutTimingFunction brings Google's new *Swift Out* animation curve to iOS.
Objective-C
44
star
15

AHKBuilder

Initialization for immutable objects based on the builder pattern.
Objective-C
39
star
16

SingleFetchedResultController

Like NSFetchedResultsController but for a single managed object.
Swift
26
star
17

StoryboardDependencyInjectionTemplates

Code generation of initializers for storyboard-based view controllers
HTML
19
star
18

BezierCurveFit

A simple app for fitting Bezier curve based on data points from another curve.
Objective-C
9
star
19

sicp

My solutions to exercises from "Structure And Interpretation Of Computer Programs"
Scheme
5
star
20

cool-compiler-examples

MIPS assembler files generated by my COOL compiler
Assembly
4
star
21

epidemic-simulation

Source code of a research project based on the use of cellular automata.
JavaScript
2
star
22

ContentOffsetJump

Source code of my answer: http://stackoverflow.com/a/19344402/1990236
Objective-C
1
star