Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
91
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
690
Profiling
jasdev
0
70
Accessing Data
jasdev
0
74
Lessons in Building APIs
jasdev
0
110
UVA ACM Interview Tips
jasdev
0
99
Other Decks in Technology
See All in Technology
Debugging Edge AI on Zephyr and Lessons Learned
iotengineer22
0
210
Python 3.14 Overview
lycorptech_jp
PRO
1
120
品質のための共通認識
kakehashi
PRO
3
260
AIと二人三脚で育てた、個人開発アプリグロース術
zozotech
PRO
1
730
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
190
今年のデータ・ML系アップデートと気になるアプデのご紹介
nayuts
1
420
AWSセキュリティアップデートとAWSを育てる話
cmusudakeisuke
0
290
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
5
530
生成AI活用の型ハンズオン〜顧客課題起点で設計する7つのステップ
yushin_n
0
210
学習データって増やせばいいんですか?
ftakahashi
2
390
Lessons from Migrating to OpenSearch: Shard Design, Log Ingestion, and UI Decisions
sansantech
PRO
1
130
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
290
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
RailsConf 2023
tenderlove
30
1.3k
Bash Introduction
62gerente
615
210k
Thoughts on Productivity
jonyablonski
73
5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
Typedesign – Prime Four
hannesfritz
42
2.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
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