ibanimatable / ibanimatable Goto Github PK
View Code? Open in Web Editor NEWDesign and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
License: MIT License
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
License: MIT License
Support Carthage to install IBAnimatable
Readme file in Chinese
Except for Spring animations, sometimes, we need linear animations.
I am using this library https://github.com/CosmicMind/Material, and want to have these components integrated with animatable feature in Interface Builder. I think moving forward I also want to have such kind of thing for any other great UI libraries. Do you have any ideas on how to get this done in the generic way.
Some feature as a plugin will only apply to prototyping in IB. Maybe useful for populating random data like names.
Flat colors like https://flatuicolors.com/ or more predefined colors.
Similar to Framer Studio.
Add one @IBInspectable
property like autoDismissKeyboard to AnimatableViewController
.
Support Rotation animation.
Material design components like MaterialButton
import IBAnimatable is a error when I open IBAnimatable.playground, how do I start it
Using path to avoid image assets?
Because @IBInspectable
in Interface Builder only support certain types. eg. CGFloat, UIColor, String and Int. But can not support enum inherited from String
. eg. enum AnimationType: String
.
@lexrus came up a great idea to use enum in programming API and use String
in IB.
#if TARGET_INTERFACE_BUILDER
/**
String value of predefined Animation Type, all supported types are in `AnimationType` enum
*/
var animationType: String? { get set }
#else
/**
Predefined Animation Type, all supported types are in `AnimationType` enum
*/
var animationType: AnimationType? { get set }
var animationTypeRaw: String? { get set }
#endif
Then when the App runs on simulator (not in IB), the compiler actually uses non TARGET_INTERFACE_BUILDER
. We have to convert the String value in Storyboard to AnimationType
. Method Swizzling on NSKeyedUnarchiver
is one way to do that.
I have tried to use Swift protocol extension.
// Use Method Swizzling to convert `String` to emun when loading runtime attributes from Storybaord.
// http://nshipster.com/swift-objc-runtime/
public extension NSKeyedUnarchiver {
public override class func initialize() {
struct Static {
static var token: dispatch_once_t = 0
}
// make sure this isn't a subclass
if self !== NSKeyedUnarchiver.self {
return
}
dispatch_once(&Static.token) {
let originalSelector = Selector("setValue:forUndefinedKey:")
let swizzledSelector = Selector("iba_setValue:forUndefinedKey:")
let originalMethod = class_getInstanceMethod(self, originalSelector)
let swizzledMethod = class_getInstanceMethod(self, swizzledSelector)
let didAddMethod = class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
if didAddMethod {
class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod))
} else {
method_exchangeImplementations(originalMethod, swizzledMethod)
}
}
}
// MARK: - Method Swizzling
func iba_setValue(value: AnyObject?, forUndefinedKey key: String) {
if (key == "animationType") {
setValue(value, forKey: "animationTypeRaw")
}
}
}
But initialize
never gets called.
Then I tried to do it in didFinishLaunchingWithOptions
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let originalSelector = Selector("setValue:forUndefinedKey:")
let swizzledSelector = Selector("iba_setValue:forUndefinedKey:")
let originalMethod = class_getInstanceMethod(NSKeyedUnarchiver.self, originalSelector)
let swizzledMethod = class_getInstanceMethod(NSKeyedUnarchiver.self, swizzledSelector)
let didAddMethod = class_addMethod(NSKeyedUnarchiver.self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
if didAddMethod {
class_replaceMethod(NSKeyedUnarchiver.self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod))
} else {
method_exchangeImplementations(originalMethod, swizzledMethod)
}
return true
}
but iba_setValue
never gets called.
Then back to @lexrus 's solution to do the Method Swizzling in Objective C.
@implementation NSKeyedUnarchiver (IBAnimatable)
- (void)iba_setValue:(id)value forUndefinedKey:(NSString *)key {
if ([key isEqualToString:@"animationType"]) {
[self setValue:value forKey:@"animationTypeRaw"];
}
}
+ (void) load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
SEL originalMethod = @selector( setValue:forUndefinedKey: );
SEL swizzledMethod = @selector( iba_setValue:forUndefinedKey: );
method_exchangeImplementations(
class_getInstanceMethod( self, originalMethod ),
class_getInstanceMethod( self, swizzledMethod )
);
});
}
@end
It is working now. And the storyboard is OK.
But once I add NSKeyedUnarchiver+IBAnimatable.m
file to IBAnimatable
framework target. Then the iba_setValue
(in NSKeyedUnarchiver+IBAnimatable.m) will not get called anymore.
Here is the changes
4a5e081...feature/support-enum-for-non-ib-api
Can design something like Apple Watch health progress ring.
Following the code, the slideOut
methods are always 300 * force
, but if we are running this example on an iPad with a force to 1, it will never get the outside screen.
Is there a reason to have hardcoding that constant?
Currently, designable border can only supports one side or 4 sides.
Currently, MaskDesignable
only supports Circle
, can support more mask like Triangle
and Star
.
Meaningful transition support
Jump up, flip and drop down.
Make UISegmentedControl
animatable, make not inherit from UISegmentedControl
.
DesignableGradientView
was a temporary view to wrap a layer. need to conform to GradientDesignable
protocol.
UIKit Dynamics support
Hello Jake,
A very nice framework you created !!!
Playground execution failed: /var/folders/9y/w9x0q7y56s78qtsn8knw_ns80000gp/T/./lldb/1191/playground15.swift:5:8: error: no such module 'IBAnimatable'
import IBAnimatable
Any suggestions (Xcode 7.2) ?
Thanks
Frank
When working with IBAnimatable, I am thinking of whether I can add an Exit animation when the controller is being dismissed. Actually with this library in place, I have an ambition to design all my apps following animations, effects demonstrated in Presentation softwares such as MS Powerpoint, Apple Keynote.
Support PieChart.
Easily to create custom dynamic type for iOS. https://www.captechconsulting.com/blogs/ios-7-tutorial-series-dynamic-type
Predefined gradient colors from http://uigradients.com/
Better syntax for chaining animations.
Just an idea
Animation(view).pop(repeatCount: 2).then.shake(repeatCount:1).and.rotate(.cw, repeatCount:2)
Make UISlider
animatable.
Support Designable and Animatable badge in BarButtonItemDesignable
It would be great to improve the github workflow:
Make this will definitely helps us to priorities and ease the development process.
Any thought?
Random name, random address, random title, random text?
Depends on Plugin for prototyping only
An AnimatableCollectionView and/or an AnimatableCollectionViewCell would be nice ๐
Support Swift package manager to install IBAnimatable
.
Make checked color or and unchecked color to be IBInspectable
. Depends on Animatable checkbox: Default checked and unchecked icon
IBInspectable
motion blur like https://github.com/fastred/MotionBlur and https://dribbble.com/shots/1212295-Pocket-iOS7-Animated-GIF
https://cocoapods.org/?q=IBAnimatable
Have you push it to pod trunk?
Support CocoaPods to install IBAnimatable
.
Not only system built-in transitions, more custom transitions support.
AnimatableNavigationController
to support custom transition animations for Push and PopAnimatableViewController
to support custom transition animations for Present and DismissAnimatableTableViewController
to support custom transition animations for Present and DismissPresent***Segue
to support custom transition animations for Present and Dismiss***InteractiveAnimator
to support gesture to Pop or Dismiss VC. e.g. Pan, ScreenEdgePan and Pinch.Currently, all animations are Spring animations, can support Easing animations as well.
Parallax effect support, useful for background images.
Openning IBAnimatableApp.xcodeproj
(there is no workspace it seems?) I get the following error:
/Users/xxx/Work/Resources/IBAnimatable/IBAnimatable/RootWindowDesignable.swift:18:32: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.
It's about 7% now.
http://cocoadocs.org/docsets/IBAnimatable/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.