Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction To Core Animation (CocoaConf Chica...
Search
corvino
March 27, 2015
Technology
79
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction To Core Animation (CocoaConf Chicago March 2015)
corvino
March 27, 2015
More Decks by corvino
See All by corvino
Core Animation for the Masses
corvino
0
70
Other Decks in Technology
See All in Technology
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
570
その Valkey 使いこなしていますか?
onk
PRO
5
1.5k
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
140
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
2.4k
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
250
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
940
Getting Started with Google Antigravity
glaforge
0
300
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
Optunaの最新リリースv5.0について
pfn
PRO
0
120
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
120
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
560
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Visualization
eitanlees
153
17k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
How to make the Groovebox
asonas
2
2.5k
RailsConf 2023
tenderlove
30
1.6k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
From π to Pie charts
rasagy
1
400
GitHub's CSS Performance
jonrohan
1033
470k
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