Eric Brotto
Eric Brotto

Reputation: 54251

CGAffineTransformMakeTranslation translate to a point rather then by a value.

My question is simple.

Let us say I use this method

CGAffineTransformMakeTranslation(5.0f, 0.0f);

which translates the image view 5 pixels to the right. But is there a similar method that does the exact same thing except takes the destination point as an argument rather then the values you want to move the image view by?

For example, if I wanted to move an image view to 100.0f, 0.0f what would I use?

Upvotes: 2

Views: 7091

Answers (2)

Fernando Cervantes
Fernando Cervantes

Reputation: 2962

You can use the following two options:

imgOne.center = CGPointMake(50, 50);

or

imgOne.frame = CGRectMake(50, 50, imgOne.frame.size.width, imgOne.frame.size.height);

Upvotes: 1

Ole Begemann
Ole Begemann

Reputation: 135548

If it's the center point you want to move to this coordinate, use:

imageView.center = CGPointMake(100.0f, 0.0f);

If it's one of the corner points, subtract/add half the view's frame's width/height to the coordinates. If you need this frequently, it's a good idea to write a small UIView category that allows you to position a view's corner on a particular coordinate.

Upvotes: 0

Related Questions