ios - How to apply multiple transforms in Swift -


i apply multiple transforms uiview (or subclass of uiview), such translate, rotate, , scale. know 2 transforms can applied cgaffinetransformconcat, how do if have 3 or more transforms?

i have seen these questions:

but these questions asking different, , given answers talk applying 2 transforms cgaffinetransformconcat. also, use objective-c rather swift.

this answer updated swift 3

you can apply multiple transforms stacking them on top of each other.

var t = cgaffinetransform.identity t = t.translatedby(x: 100, y: 300) t = t.rotated(by: cgfloat.pi / 4) t = t.scaledby(x: -1, y: 2) // ... add many want, apply to view imageview.transform = t 

or more compactly (but not readable):

imageview.transform = cgaffinetransform.identity.translatedby(x: 100, y: 300).rotated(by: cgfloat.pi / 4).scaledby(x: -1, y: 2) 

this series of transforms produces image on right:

enter image description here

thanks this answer teaching me how it.

notes

  • the order in apply transforms matters.

see also


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -