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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Jasdev Singh
March 22, 2016
Technology
0
93
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
80
Hidden Gems in Swift
jasdev
6
1.4k
Swift 2.2 & 3.0 Changes
jasdev
1
700
Profiling
jasdev
0
70
Accessing Data
jasdev
0
77
Lessons in Building APIs
jasdev
0
110
UVA ACM Interview Tips
jasdev
0
99
Other Decks in Technology
See All in Technology
BiDiってなんだ?
tomorrowkey
2
510
いよいよ仕事を奪われそうな波が来たぜ
kazzpapa3
3
300
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
4
600
新規事業 toitta におけるAI 機能評価の話 / AI Feature Evaluation in toitta
pokutuna
0
290
GCASアップデート(202510-202601)
techniczna
0
210
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
みんなだいすきALB、NLBの 仕組みから最新機能まで総おさらい / Mastering ALB & NLB: Internal Mechanics and Latest Innovations
kaminashi
0
150
書籍執筆での生成AIの活用
sat
PRO
1
230
Tebiki Engineering Team Deck
tebiki
0
23k
新規事業における「一部だけどコア」な AI精度改善の優先順位づけ
zerebom
0
440
AIとともに歩む情報セキュリティ / Information Security with AI
kanny
4
2.8k
開発メンバーが語るFindy Conferenceの裏側とこれから
sontixyou
2
400
Featured
See All Featured
A Tale of Four Properties
chriscoyier
162
24k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
100
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
170
30 Presentation Tips
portentint
PRO
1
200
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
88
Building Adaptive Systems
keathley
44
2.9k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
390
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
70
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Making Projects Easy
brettharned
120
6.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