0

I've been looking stackoverflow and the internet for quite some time, but can't seem to find anything usable.

I'd like to achieve this: UIImage distortion

Where it's important that I can change the four corner's origin. Something like this:

imageView.layer.somethingMagic.imageRightTop = (CGPoint){ 230, 30 };
imageView.layer.somethingMagic.imageRightBottom = (CGPoint){ 300, 150 };

and it result into a deformed "3D" image.

I don't need actually working code, just some pointers where/what to look for.

max_
  • 24,076
  • 39
  • 122
  • 211
basvk
  • 4,437
  • 3
  • 29
  • 49
  • See this similar question for a discussion of how to do distortions like this with a CATransform3D: http://stackoverflow.com/questions/2351586/iphone-image-stretching-skew – Brad Larson Jul 12 '12 at 17:52

1 Answers1

0

You need to use CGAffineTransformConcat / CGAffineTransformDistort. There is a tutorial here showing how to do it:

http://b2cloud.com.au/how-to-guides/ios-distort-transform

#define CGAffineTransformDistort(t, x, y) (CGAffineTransformConcat(t, CGAffineTransformMake(1, y, x, 1, 0, 0)))
#define CGAffineTransformMakeDistort(x, y) (CGAffineTransformDistort(CGAffineTransformIdentity, x, y))

Obviously don't use it in a UIViewAnimation as shown in the example on the above page.

Community
  • 1
  • 1
max_
  • 24,076
  • 39
  • 122
  • 211
  • That will only work for skewing, as described by KennyTM here: http://stackoverflow.com/a/2352402/19679 . A 2-D affine transform will not be able to achieve the effect they want in the image above. – Brad Larson Jul 12 '12 at 17:50