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
67
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
54
Hidden Gems in Swift
jasdev
6
1.3k
Swift 2.2 & 3.0 Changes
jasdev
1
640
Profiling
jasdev
0
47
Accessing Data
jasdev
0
59
Lessons in Building APIs
jasdev
0
84
UVA ACM Interview Tips
jasdev
0
75
Other Decks in Technology
See All in Technology
Vos logs méritent mieux que la config par défaut
lyrixx
2
380
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
250
業務で使えるかもしれない…!?GitHub Actions の Tips 集 / CI/CD Test Night #7
ponkio_o
PRO
24
7.1k
技術広報として2023年度に頑張ったこと / What we did well in FY2023 as a DevRel
pauli
5
490
Building a RAG app to chat with your data (on Azure)
pamelafox
0
120
こんなに簡単!AWSマルチアカウント
takuya_terada
0
120
10分でわかるfreeeのQA
freee
0
260
ハイパフォーマンスな組織をつくるための開発生産性の考え方 / developer-productivity-high-performer-link-and-motivation
lmi
3
270
VSCode上からSlackにメッセージを送る拡張機能を作っている話
ebarakazuhiro
0
120
#51 “Empowering Azure Storage with RDMA”
cafenero_777
3
210
KTC_DBRE.pdf
_awache
1
290
Evolutionary Optimization of Model Merging Recipes
fuyu_quant0
3
550
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
10
4.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
14
2.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Large-scale JavaScript Application Architecture
addyosmani
501
110k
From Idea to $5000 a Month in 5 Months
shpigford
376
45k
Optimizing for Happiness
mojombo
369
69k
Infographics Made Easy
chrislema
237
18k
Into the Great Unknown - MozCon
thekraken
10
830
How to name files
jennybc
62
92k
A better future with KSS
kneath
230
16k
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