Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ashfurrow/uiview-booleananimations

Perform changes to UI with or without animations, depending on a variable.
https://github.com/ashfurrow/uiview-booleananimations

Last synced: about 2 months ago
JSON representation

Perform changes to UI with or without animations, depending on a variable.

Awesome Lists containing this project

README

        

UIView-BooleanAnimations
========================

Perform changes to UI with or without animations, depending on a variable.

Installation
------------

Add the following to your Podfile.

```ruby
pod 'UIView+BooleanAnimations'
```

Tun `pod install` and then use one of the following import statements, depending on if you're using frameworks and ObjC/Swift:

```objc
// With Framworks
@import UIView_BooleanAnimations;

// With static libraries
#import
```

```swift
// With Swift
import UIView_BooleanAnimations
```

Use
---

``` objc
@interface UIView (BooleanDependantAnimation)

/// Optionally runs animations based on a bool, performs block right away if not true
+ (void)animateIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration :(void (^)(void))animations;

/// Optionally runs animations based on a bool, performs animation + completion right away if not true
+ (void)animateIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration :(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

/// Only animates if shouldAnimate is true, otherwise will perform block synchronously with options
+ (void)animateIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options :(void (^)(void))animations;

/// Only animates with delay and options if shouldAnimate is true, otherwise will perform block synchronously and perform completion in the same manner
+ (void)animateIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options :(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

/// Optionally runs spring based animations based on a bool, performs animation right away if not true
+ (void)animateSpringIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration delay:(NSTimeInterval)delay damping:(CGFloat)damping velocity:(CGFloat)velocity :(void (^)(void))animations;

/// Optionally runs spring based animations based on a bool, performs animation + completion right away if not true
+ (void)animateSpringIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration delay:(NSTimeInterval)delay damping:(CGFloat)damping velocity:(CGFloat)velocity :(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

// Adds a subview and fades it's alpha to 1, or adds the subview straight away
- (void)addSubview:(UIView *)view andFadeInForDuration:(CGFloat)duration if:(BOOL)shouldAnimate;

// Fades a subview's alpha to 0 then removes, or syncronously removes the subview
- (void)removeFromSuperviewAndFadeOutWithDuration:(CGFloat)duration if:(BOOL)shouldAnimate;

/// Useful for a fade animation
+ (void)animateTwoStepIf:(BOOL)shouldAnimate duration:(NSTimeInterval)duration :(void (^)(void))initialAnimations midway:(void (^)(void))midwayAnimations completion:(void (^)(BOOL finished))completion;

@end
```