Latest 1.0.2
Homepage https://github.com/ashfurrow/UIView-BooleanAnimations
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit
Authors , ,

UIView-BooleanAnimations

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

Installation

Add the following to your Podfile.

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:

// With Framworks
@import UIView_BooleanAnimations;

// With static libraries
#import <UIView+BooleanAnimations/UIView+BooleanAnimations.h>
// With Swift
import UIView_BooleanAnimations

Use

@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

Latest podspec

{
    "name": "UIView+BooleanAnimations",
    "version": "1.0.2",
    "summary": "Perform changes to UI with or without animations, depending on a variable.",
    "description": "                    Perform changes to UI with or without animations, depending on a variable. n                    This is really useful for performing unit tests on view controllers without a delay. n",
    "homepage": "https://github.com/ashfurrow/UIView-BooleanAnimations",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ash Furrow": "[email protected]",
        "Orta Therox": "[email protected]",
        "Laura Brown": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/ashfurrow/UIView-BooleanAnimations.git",
        "tag": "1.0.2"
    },
    "source_files": "UIView+BooleanAnimations.{h,m}",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This