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
77
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
59
Hidden Gems in Swift
jasdev
6
1.3k
Swift 2.2 & 3.0 Changes
jasdev
1
640
Profiling
jasdev
0
57
Accessing Data
jasdev
0
62
Lessons in Building APIs
jasdev
0
89
UVA ACM Interview Tips
jasdev
0
86
Other Decks in Technology
See All in Technology
より快適なエラーログ監視を目指して
leveragestech
4
1.4k
持続可能なソフトウェア開発を支える『GitHub CI/CD実践ガイド』
tmknom
7
1.4k
株式会社EventHub・エンジニア採用資料
eventhub
0
2.9k
ロリポップ! for Gamersを支えるインフラ/lolipop for gamers infrastructure
takumakume
0
130
OR学会2024秋_短期収益と将来のオフ方策評価性能を考慮したクーポン割当方策混合比の決定
recruitengineers
PRO
4
460
事前準備が肝!AI活用のための業務改革
layerx
PRO
1
380
実務における脅威モデリングを考えよう
nikinusu
0
630
LLVM/ASMを使った有限体の高速実装
herumi
0
120
とあるOSSを継続可能にするための取り組みについて / OSS Refactoring Process
bun913
1
210
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
250
Google CloudのLLM活用の選択肢を広げるVertex AIのパートナーモデル
nayuts
0
130
「認証認可」という体験をデザインする ~Nekko Cloud認証認可基盤計画
logica0419
2
440
Featured
See All Featured
Creatively Recalculating Your Daily Design Routine
revolveconf
215
12k
Designing Experiences People Love
moore
138
23k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
123
18k
Building an army of robots
kneath
302
42k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
502
140k
How GitHub (no longer) Works
holman
310
140k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
58k
Unsuck your backbone
ammeep
667
57k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
The Language of Interfaces
destraynor
153
23k
Web development in the modern age
philhawksworth
205
10k
Music & Morning Musume
bryan
46
6k
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