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
78
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
62
Hidden Gems in Swift
jasdev
6
1.3k
Swift 2.2 & 3.0 Changes
jasdev
1
640
Profiling
jasdev
0
58
Accessing Data
jasdev
0
64
Lessons in Building APIs
jasdev
0
91
UVA ACM Interview Tips
jasdev
0
89
Other Decks in Technology
See All in Technology
Can We Measure Developer Productivity?
ewolff
1
150
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
Terraform Stacks入門 #HashiTalks
msato
0
350
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
380
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
470
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.2k
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Statistics for Hackers
jakevdp
796
220k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
How to Ace a Technical Interview
jacobian
276
23k
How STYLIGHT went responsive
nonsquared
95
5.2k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Bash Introduction
62gerente
608
210k
Designing Experiences People Love
moore
138
23k
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