Questions tagged [cgaffinetransform]

The CGAffineTransform represents a matrix used for affine transformations. A transformation specifies how points in one coordinate system map to points in another coordinate system. An affine transformation is a special type of mapping that preserves parallel lines in a path but does not necessarily preserve lengths or angles. Scaling, rotation, and translation are the most commonly used manipulations supported by affine transforms.

The CGAffineTransform data structure represents a matrix used for affine transformations. A transformation specifies how points in one coordinate system map to points in another coordinate system. An affine transformation is a special type of mapping that preserves parallel lines in a path but does not necessarily preserve lengths or angles. Scaling, rotation, and translation are the most commonly used manipulations supported by affine transforms, but skewing is also possible.

Quartz provides functions that create, concatenate, and apply affine transformations using the CGAffineTransform data structure. For information on how to use affine transformation functions, see Quartz 2D Programming Guide.

You typically do not need to create an affine transform directly—CGContext Reference describes functions that modify the current affine transform. If you don’t plan to reuse an affine transform, you may want to use CGContextScaleCTM, CGContextRotateCTM, CGContextTranslateCTM, or CGContextConcatCTM.

Functions

Creating an Affine Transformation Matrix

CGAffineTransformMake

CGAffineTransformMakeRotation

CGAffineTransformMakeScale

CGAffineTransformMakeTranslation

Modifying Affine Transformations

CGAffineTransformTranslate

CGAffineTransformScale

CGAffineTransformRotate

CGAffineTransformInvert

CGAffineTransformConcat

Applying Affine Transformations

CGPointApplyAffineTransform

CGSizeApplyAffineTransform

CGRectApplyAffineTransform

Evaluating Affine Transforms

CGAffineTransformIsIdentity

CGAffineTransformEqualToTransform

Data Types

CGAffineTransform

Constants

CGAffineTransformIdentity

831 questions
66
votes
3 answers

How to apply multiple transforms in Swift

I would like to apply multiple transforms to a UIView (or subclass of UIView), such as translate, rotate, and scale. I know that two transforms can be applied with CGAffineTransformConcat, but how do I do it if I have three or more transforms? I…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
46
votes
5 answers

One step affine transform for rotation around a point?

How can I make a Core Graphics affine transform for rotation around a point x,y of angle a, using only a single call to CGAffineTransformMake() plus math.h trig functions such as sin(), cos(), etc., and no other CG calls. Other answers here seem to…
hotpaw2
  • 70,107
  • 14
  • 90
  • 153
45
votes
5 answers

CGAffineTransform Reset

3I have an image that gets manipulated by touch. Lets say its an image of an arrow that points up. After it's been rotated 180 degrees, so the arrow is pointing down now, I want to reset CGAffineTransform properties so that it thinks now its turned…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
44
votes
11 answers

Max/Min Scale of Pinch Zoom in UIPinchGestureRecognizer - iPhone iOS

How would I be able to limit the scale of the UIPinchGestureRecognizer to a min and max level? The scale property below seems to be relative to the last known scale (the delta from last state) and I can't figure out how to set a limit to the…
VinnyD
  • 3,500
  • 9
  • 34
  • 48
35
votes
7 answers

Find Frame Coordinates After UIView Transform is Applied (CGAffineTransform)

I rotate my view with CGAffineTransform [view setTransform:newTransform]; The frame values remain the same after transform is applied but how do I find "rotated" or transformed values of this frame? (source: informit.com) I want the exact…
Vad
  • 3,658
  • 8
  • 46
  • 81
34
votes
3 answers

Scale with CGAffineTransform and set the anchor

If I understand correctly scaling a UIView with CGAffineTransform anchors the transformation to its center. In particular: self.frame = CGRectMake(0,0,100,100); self.transform = CGAffineTransformMakeScale(2, 2); NSLog(@"%f;%f;%f;%f",…
hpique
  • 119,096
  • 131
  • 338
  • 476
33
votes
1 answer

Convert coordinates between parent/child UIView after CGAffineTransform

Before I go into doing everything by hand I would like to ask if there is some help to get from the framework. I have a UIView that holds another UIView with a map. The parent UIView holds some legends for the map. Initially I define some…
RickiG
  • 11,380
  • 13
  • 81
  • 120
32
votes
5 answers

CGAffineTransform scale and translation - jump before animation

I am struggling with an issue regarding CGAffineTransform scale and translation where when I set a transform in an animation block on a view that already has a transform the view jumps a bit before animating. Example: // somewhere in view did load…
matteok
  • 2,189
  • 3
  • 30
  • 54
25
votes
2 answers

iOS: Mirror content on screen

I would like to know if it is possible to flip the contents of a UIView within the same device; meaning not to an external monitor but on the device itself. I have searched a bit on google, but all I can find is to external screens.
Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
23
votes
8 answers

Get just the scaling transformation out of CGAffineTransform

I found a similar question about getting just the rotation, but as I understand scaling and rotating work different in the transform matrix. Matrixes are not my strength, so if anybody would hint me how to get only the scaling out of a…
Marin Todorov
  • 6,377
  • 9
  • 45
  • 73
21
votes
7 answers

Get size of UIView after applying CGAffineTransform

I was surprised not to find an answer to this question, maybe is something very simple I somehow overlook : How to get the real size of an UIView after I apply a CGAffineTransform to it? eg. my UIView has size 300 x 200, I apply a scaling…
Marin Todorov
  • 6,377
  • 9
  • 45
  • 73
21
votes
2 answers

Animation Grow/Decrease Size imageView iOS

I'm trying to animate a custom button using CGAffineTransformMakeScale as follows: if (stateButton == 0) { //The button is gonna appear self.selected = YES; self.imageView.transform = CGAffineTransformMakeScale(0.01, 0.01); [UIView…
21
votes
4 answers

iOS translation and scale animation

I'm working on UIButton animation where: The UIButton is set in the bottom center of the screen and scaled to a small size _menuBtn.transform = CGAffineTransformMakeScale(0.1f, 0.1f); When the app starts it should be moving to the bottom left side…
Jrey Quiros
  • 233
  • 1
  • 3
  • 10
20
votes
2 answers

(Scale) Zoom into a UIView at a point

Something I don't understand about transformations. I want to zoom in to say the top right corner of a UIView (the main view). I use CGAffineTransformScale and have tried both setting the center/anchorPoint as well as…
akaru
  • 6,299
  • 9
  • 63
  • 102
20
votes
6 answers

Animation of CGAffineTransform in iOS8 looks different than in iOS7

I'm trying to find a reason why animation of UIView transform property looks different in iOS 8 than iOS 6/7. For a simple example, prior to iOS 8: myView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, 1.57); [UIView…
maniacus
  • 381
  • 1
  • 3
  • 9
1
2 3
55 56