Let's assume you have a variable named imageView
holding a reference to your UIImageView
.
I wrote a little sample to demonstrate how you could get this behavior. What this code does is creating a new CGAffineTransform
matrix. This matrix has the same values as the identity transform matrix with one exception: the value at location [2,1]. This value is controlled by the c
-parameter of the CGAffineTransformMake
-function and controls the shearing along the x-axis. You can change the amount of shearing by setting shearValue
.
The code:
Objective-C
CGFloat shearValue = 0.3f; // You can change this to anything you want
CGAffineTransform shearTransform = CGAffineTransformMake(1.f, 0.f, shearValue, 1.f, 0.f, 0.f);
[imageView setTransform:shearTransform];
Swift 5
let shearValue = CGFloat(0.3) // You can change this to anything you want
let shearTransform = CGAffineTransform(a: 1, b: 0, c: shearValue, d: 1, tx: 0, ty: 0)
imageView.transform = shearTransform
And here's what the shearTransform
-matrix looks like:
[1 0 0]
[0.3 1 0]
[0 0 1]