Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
73
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
65
Other Decks in Technology
See All in Technology
OCI Oracle Database Services新機能アップデート(2025/06-2025/08)
oracle4engineer
PRO
0
110
品質視点から考える組織デザイン/Organizational Design from Quality
mii3king
0
200
下手な強制、ダメ!絶対! 「ガードレール」を「檻」にさせない"ガバナンス"の取り方とは?
tsukaman
2
420
Generative AI Japan 第一回生成AI実践研究会「AI駆動開発の現在地──ブレイクスルーの鍵を握るのはデータ領域」
shisyu_gaku
0
140
allow_retry と Arel.sql / allow_retry and Arel.sql
euglena1215
1
160
Obsidian応用活用術
onikun94
1
470
MCPで変わる Amebaデザインシステム「Spindle」の開発
spindle
PRO
3
3.2k
企業の生成AIガバナンスにおけるエージェントとセキュリティ
lycorptech_jp
PRO
2
160
データアナリストからアナリティクスエンジニアになった話
hiyokko_data
2
440
Function Body Macros で、SwiftUI の View に Accessibility Identifier を自動付与する/Function Body Macros: Autogenerate accessibility identifiers for SwiftUI Views
miichan
2
180
自作JSエンジンに推しプロポーザルを実装したい!
sajikix
1
170
職種の壁を溶かして開発サイクルを高速に回す~情報透明性と職種越境から考えるAIフレンドリーな職種間連携~
daitasu
0
140
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
920
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
KATA
mclloyd
32
14k
4 Signs Your Business is Dying
shpigford
184
22k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Code Reviewing Like a Champion
maltzj
525
40k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
A designer walks into a library…
pauljervisheath
207
24k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
The Cost Of JavaScript in 2023
addyosmani
53
8.9k
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