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
Tranformations - Core Animation
Search
Jasdev Singh
March 22, 2016
Technology
0
84
Tranformations - Core Animation
Chapter review from Nick Lockwood's Core Animation book at Tumblr's iOS Book Club
Jasdev Singh
March 22, 2016
Tweet
Share
More Decks by Jasdev Singh
See All by Jasdev Singh
Tuning for Speed
jasdev
0
72
Hidden Gems in Swift
jasdev
6
1.3k
Swift 2.2 & 3.0 Changes
jasdev
1
680
Profiling
jasdev
0
62
Accessing Data
jasdev
0
69
Lessons in Building APIs
jasdev
0
96
UVA ACM Interview Tips
jasdev
0
94
Other Decks in Technology
See All in Technology
うちの会社の評判は?SNSの投稿分析にAIを使ってみた
doumae
0
270
SmartHRの複数のチームにおけるMCPサーバーの活用事例と課題
yukisnow1823
2
1.2k
Data Hubグループ 紹介資料
sansan33
PRO
0
1.7k
MCP で繋ぐ Figma とデザインシステム〜LLM を使った UI 実装のリアル〜
kimuson
2
1.3k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
12k
AIの電力問題を概観する
rmaruy
1
220
コードの考古学 〜労務システムから発掘した成長の糧〜
kenta_smarthr
1
1.2k
プラットフォームとしての Datadog / Datadog as Platforms
aoto
PRO
1
340
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
17k
從開發到架構設計的可觀測性實踐
philipz
0
110
FastMCPでSQLをチェックしてくれるMCPサーバーを自作してCursorから動かしてみた
nayuts
1
220
データ戦略部門 紹介資料
sansan33
PRO
1
3.1k
Featured
See All Featured
Side Projects
sachag
454
42k
YesSQL, Process and Tooling at Scale
rocio
172
14k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
It's Worth the Effort
3n
184
28k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Building Applications with DynamoDB
mza
95
6.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
25
2.8k
For a Future-Friendly Web
brad_frost
178
9.7k
Statistics for Hackers
jakevdp
799
220k
Code Review Best Practice
trishagee
68
18k
Thoughts on Productivity
jonyablonski
69
4.7k
Transcript
TRANSFORMATIONS IOS BOOK CLUB JASDEV SINGH
AFFINE TRANSFORMATIONS > Rotation > CGAffineTransformMakeRotation(_:) > Scaling > CGAffineTransformMakeScale(_:_:)
> Translations > CGAffineTransformMakeTranslation(_:_:)
UIView transform PROPERTY Really just a wrapper on the underlying
CALayer feature, affineTransform.
COMPOSING TRANSFORMATIONS Core Graphics provides functions that take existing transformations
and applies another on top of it. > CGAffineTransformRotate(_:_:) > CGAffineTransformScale(_:_:_:) > CGAffineTransformTranslate(_:_:_:) > CGAffineTransformConcat(_:_:)
SAMPLE TRANSFORMATION > 50% scale > Rotate 30 degrees >
Vertical translation by 200 points public func +(lhs: CGAffineTransform, rhs: CGAffineTransform) -> CGAffineTransform { return CGAffineTransformConcat(lhs, rhs) }
import UIKit class ViewController: UIViewController { let view1 = UIView()
override func viewDidLoad() { super.viewDidLoad() view1.backgroundColor = .greenColor() view1.frame = CGRect(origin: view.center, size: CGSize(width: 150, height: 150)) view.addSubview(view1) let transform = CGAffineTransformIdentity + CGAffineTransformMakeScale(0.5, 0.5) + CGAffineTransformMakeRotation(CGFloat(M_PI) / 180 * 30) + CGAffineTransformMakeTranslation(0, 200) view1.layer.setAffineTransform(transform) } }
None
ARTISANAL TRANSFORMATIONS If you need to to make custom affine
transformations that aren't built into Core Graphics, you can directly set values on the transformation matrix:
3D TRANSFORMS The transform property on CALayer is of type
CATransform3D. > CATransform3DMakeRotation(_:_:_:_:) > CATransform3DMakeScale(_:_:_:) > CATransform3DMakeTranslation(_:_:_:)
Perspective Projections By default, Core Animation uses isometric projections, which
preserves parallel lines in 3D space. To give our 3D transformations a sense of depth, we have to add a perspective transform .
By default, . To apply perspective, set to , where
is the distance between the imaginary camera and the screen, in points. usually works well.
sublayerTransform PROPERTY A CATranmsform3D property on CALayer that allows you
to apply a transform to all sublayers!
doubleSided PROPERTY