Canvas --高效的 iOS 動畫庫

Canvas.gif

canvaf.gif

Canvas 是什么?

canvas 是一個非常高效且實用簡單的 iOS 動畫庫,只需要非常簡潔的代碼,就能實現很多常用的效果。官方的口號是 “Animate in Xcode without code ”。

canvas 包涵 29 種常用的動畫效果,這些效果可以應用在很多地方,如當我們點擊評分、收藏、贊時按鈕的動態效果。

                            CSAnimationTypePop ,
                            CSAnimationTypeMorph  ,
                            CSAnimationTypeFlash ,
                            CSAnimationTypeShake ,
                            CSAnimationTypeFadeOut,
                            CSAnimationTypeFadeInLeft ,
                            CSAnimationTypeFadeInRight,
                            CSAnimationTypeFadeInDown ,
                            CSAnimationTypeFadeInUp ,
                            CSAnimationTypeSlideLeft,
                            CSAnimationTypeSlideRight,
                            CSAnimationTypeSlideDown ,
                            CSAnimationTypeSlideUp ,
                            CSAnimationTypeZoomIn,
                            CSAnimationTypeZoomOut ,
                            CSAnimationTypeSlideDownReverse ,
                            CSAnimationTypeBounceLeft,
                            CSAnimationTypeBounceRight,
                            CSAnimationTypeBounceDown,
                            CSAnimationTypeBounceUp,
                            CSAnimationTypeFadeIn,
                            CSAnimationTypeFadeInSemi ,
                            CSAnimationTypeFadeOutSemi  ,
                            CSAnimationTypeFadeOutRight  ,
                            CSAnimationTypeFadeOutLeft  ,
                            CSAnimationTypePopDown ,
                            CSAnimationTypePopAlpha ,
                            CSAnimationTypePopAlphaUp ,
                            CSAnimationTypePopAlphaOut

如何使用 Canvas ?

1、CocoaPods
platform :ios, '7.0'
pod 'Canvas', '~> 0.1.2'
2、 在 storyboard 中使用。

設置一個 View 繼承 CSAnimationView,然后通過 runtime Attribute 設置動畫屬性,如類型、時間、延遲等。

CSAnimationView.png

關于 runtime Attribute ,在 運行時你設置的這個屬性才會起作用,是Objective-C語言的動態特性和運行時(runtime)的強大。詳情請見:

http://yulingtianxia.com/blog/2014/11/05/objective-c-runtime/
http://wufawei.com/2013/11/ios-application-security-3/

3、Using Code

非常簡單只需幾行代碼。

#import "Canvas.h"
CSAnimationView *animationView = [[CSAnimationView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
animationView.backgroundColor = [UIColor whiteColor];
animationView.duration = 0.5;
animationView.delay = 0;
animationView.type = CSAnimationTypeMorph;
[self.view addSubview:animationView];

//添加你想增加效果的 View 為 animationView 的子視圖
// [animationView addSubview:<#(UIView *)#>]

[animationView startCanvasAnimation];

GitHub & Website

https://github.com/CanvasPod/Canvas
http://canvaspod.io

https://github.com/lioonline/CanvasDemo

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容