A useful UIView
category containing a set of most commonly used animations like rotation, flip, shake and others.
It is designed to be as easy to use and integrate as possible with a goal to speed up everyday development tasks. All the methods are well documented and described.
Furthermore, the category comes along with a small demo project where you can see the animations in action.
Animations
Extension contains helper methods for the following animations:
Rotation
[boxView rotateToAngle:M_PI * 2.0f
duration:1.0f
direction:UIViewAnimationRotationDirectionLeft
repeatCount:HUGE_VALF
autoreverse:YES];
Flip
[boxView flipWithDuration:0.3f
direction:UIViewAnimationFlipDirectionFromLeft
repeatCount:2
autoreverse:NO];
Vertical Shake
[boxView shakeVertically];
Horizontal Shake
[boxView shakeHorizontally];
Pulse
[boxView pulseToSize:1.1f
duration:0.3f
repeat:YES];
Motion Effects
[boxView applyMotionEffects];
Can't be shown in a gif. Run on the device to see it in action.
Installation
The recommended approach for installing Animation Extensions is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation.
via CocoaPods
Install CocoaPods if not already available:
$ [sudo] gem install cocoapods
$ pod setup
Change to the directory of your Xcode project, and Create and Edit your Podfile
and add Animation Extensions:
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
target "YOUR PROJECT" do
platform :ios, '11.0'
pod 'UIView+AnimationExtensions', '~> 2.0.0'
end
Install into your project:
$ pod install
Open your project in Xcode from the .xcworkspace file (not the usual project file)
$ open MyProject.xcworkspace
Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. You can get a full picture of the installation details by executing pod install --verbose
.
Using Animation Extensions in a Swift Project
Install Animation Extensions using one of the above methods. Then
-
If Animation Extensions are built as a dynamic framework, add:
@import UIView+AnimationExtensions;
-
If Animation Extensions are built as a static library, add into the bridging header for your Swift project:
#import <UIView+AnimationExtensions/UIView+AnimationExtensions.h>
Thread Safety
UIView Animation Extensions is a category on UIView
and - as with all UIKit
components - it should only be accessed from the main thread.
License
This code is distributed under the terms and conditions of the CC0 v1.0 license.
Copyright (c) 2017 Rafał Sroka
Credits
Animation Extensions are brought to you by Rafał Sroka.