Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction To Core Animation (CocoaConf Chica...
Search
corvino
March 27, 2015
Technology
1
75
Introduction To Core Animation (CocoaConf Chicago March 2015)
corvino
March 27, 2015
Tweet
Share
More Decks by corvino
See All by corvino
Core Animation for the Masses
corvino
0
67
Other Decks in Technology
See All in Technology
プロダクトマネージャーが押さえておくべき、ソフトウェア資産とAIエージェント投資効果 / pmconf2025
i35_267
2
590
LLM-Readyなデータ基盤を高速に構築するためのアジャイルデータモデリングの実例
kashira
0
210
AWS CLIの新しい認証情報設定方法aws loginコマンドの実態
wkm2
5
560
Playwrightのソースコードに見る、自動テストを自動で書く技術
yusukeiwaki
13
5k
Overture Maps Foundationの3年を振り返る
moritoru
0
160
Microsoft Agent 365 を 30 分でなんとなく理解する
skmkzyk
1
1k
手動から自動へ、そしてその先へ
moritamasami
0
280
今年のデータ・ML系アップデートと気になるアプデのご紹介
nayuts
1
140
SSO方式とJumpアカウント方式の比較と設計方針
yuobayashi
7
510
小さな判断で育つ、大きな意思決定力 / 20251204 Takahiro Kinjo
shift_evolve
PRO
1
580
re:Invent2025 コンテナ系アップデート振り返り(+CloudWatchログのアップデート紹介)
masukawa
0
310
ログ管理の新たな可能性?CloudWatchの新機能をご紹介
ikumi_ono
1
530
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Faster Mobile Websites
deanohume
310
31k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Being A Developer After 40
akosma
91
590k
Facilitating Awesome Meetings
lara
57
6.7k
How STYLIGHT went responsive
nonsquared
100
6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Designing Experiences People Love
moore
143
24k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Transcript
Introduction to Core Animation Nathan Corvino March 27, 2015
UIView Animations [UIView animateWithDuration:1.2 animations:^{ self.targetView.bounds = CGRectMake(0., 0., 100.,
100.); self.targetView.center = CGPointMake(50., 50); self.targetView.backgroundColor = [UIColor redColor]; self.targetView.alpha = 0.5; }];
None
CALayer • Manage content, geometry, and visual attributes • Content
Cache (Bitmap/Texture) • GPU!
• anchorPoint • backgroundColor • backgroundFilters • borderColor • borderWidth
• bounds • compositingFilter • contents • contentsRect • cornerRadius • doubleSided • filters • hidden • mask • masksToBounds • opacity • position • shadowColor • shadowOffset • shadowOpacity • shadowPath • shadowRadius • sublayers • sublayerTransform • transform • zPosition
• anchorPoint • backgroundColor • backgroundFilters • borderColor • borderWidth
• bounds • compositingFilter • contents • contentsRect • cornerRadius • doubleSided • filters • hidden • mask • masksToBounds • opacity • position • shadowColor • shadowOffset • shadowOpacity • shadowPath • shadowRadius • sublayers • sublayerTransform • transform • zPosition • frame
Demo
• anchorPoint • backgroundColor • backgroundFilters • borderColor • borderWidth
• bounds • compositingFilter • contents • contentsRect • cornerRadius • doubleSided • filters • hidden • mask • masksToBounds • opacity • position • shadowColor • shadowOffset • shadowOpacity • shadowPath • shadowRadius • sublayers • sublayerTransform • transform • zPosition
• anchorPoint • backgroundColor • backgroundFilters • borderColor • borderWidth
• bounds • compositingFilter • contents • contentsRect • cornerRadius • doubleSided • filters • hidden • mask • masksToBounds • opacity • position • shadowColor • shadowOffset • shadowOpacity • shadowPath • shadowRadius • sublayers • sublayerTransform • transform • zPosition
• anchorPoint • backgroundColor • backgroundFilters • borderColor • borderWidth
• bounds • compositingFilter • contents • contentsRect • cornerRadius • doubleSided • filters • hidden • mask • masksToBounds • opacity • position • shadowColor • shadowOffset • shadowOpacity • shadowPath • shadowRadius • sublayers • sublayerTransform • transform • zPosition
UIView Animations [UIView animateWithDuration:1.0 animations:^{ … }]; [UIView animateWithDuration:1.2 delay:0.
options:UIViewAnimationOptionCurveEaseInOut animations:^{ … } completion:^(BOOL finished) { … }];
UIView Animations [UIView animateWithDuration:1.2 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{ … } completion:^(BOOL
finished) { [UIView animateWithDuration:1.2 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{ … } } completion:^(BOOL finished) { … } }]; Chain Animations
Timing • Linear • EaseIn • EaseOut • EaseIn-EaseOut •
Default • Custom
Linear EaseIn EaseOut EaseIn-EaseOut
Implicit vs Explicit • UIView-based • sublayers • Disable with
CATransaction • CAAnimation
Explicit Animations CABasicAnimation *theAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"]; theAnimation.fromValue = [NSValue
valueWithCGRect:self.targetView.bounds]; theAnimation.toValue = [NSValue valueWithCGRect:newBounds]; theAnimation.duration = 1.2; [self.targetView.layer addAnimation:theAnimation forKey:@"AnimateFrame"]; self.targetView.bounds = newBounds; CABasicAnimation
Explicit Animations • CABasicAnimation • CAAnimationGroup • CAKeyFrameAnimation
Key Frame Animations 1 2 3 4 5
Key Frame Animations
CALayer Subclasses • CAShapeLayer • CATiledLayer • CATextLayer • AV
Layers (CACaptureVideoPreviewLayer, AVPlayerLayer, etc.) • CAGradientLayer • CATextLayer
CAShapeLayer CAShapeLayer *shape = [CAShapeLayer layer]; shape.frame = someFrame; shape.strokeColor
= [UIColor greenColor].CGColor; shape.lineWidth = 3.; shape.fillColor = [UIColor yellowColor].CGColor; shape.path = CGPathCreateWithEllipseInRect( CGRectMake(0., 0., someFrame.size.width, someFrame.size.height), &CGAffineTransformIdentity);
CATiledLayer SomeTiledLayerDelegate *tiledDelegate = [[SomeTiledLayerDelegate alloc] init]; CATiledLayer *tiledLayer =
[CATiledLayer layer]; tiledLayer.delegate = tiledDelegate; tiledLayer.frame = CGRectMake(...); tiledLayer.contentsScale = [[UIScreen mainScreen] scale]; @implementation SomeTiledLayerDelegate - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { CGRect box = CGContextGetClipBoundingBox(context); // ... } @end
Best Practices • Avoid offscreen rendering—Simulator shows • shouldRasterize can
help; it can also hurt. • Blending is still expensive.
Thanks! • @corvino •
[email protected]
• github.com/corvino/LayerExplorer