UIView transform - ios

I got an UIView with 4 views in the corners which will be dragged to create a perspective effect. This is how it looks like in the beggining:
Once the user drags a view, it will create a transform effect. For example:
I investigated it and I figured out I have to use CALayer to do that, but I'm still no clearer on how to create this kind of transform on an iPhone. Any help, pointers or example code snippets would be really appreciated!
Thanks!

You should search for CATransform3D. But this is kind of a good start.

Related

How to create a complex SVG layer fill animation based on CAShapeLayer

As you can understand from the title of this question I am trying to achieve fill animation of CALayer(CAShapeLayer) of SVG file.
How complex should be animation you can see from the images I attached.
I decided to start just with a circle and animate it to fill a layer below. Everything works pretty well.
So, I started building UIBezierPath or something like that but it looks like I am going the wrong direction.
I would really appreciate if you can just give me different ideas how to achieve it.
For SVG I use SVGKit. Maybe by using these set of classes, I can do something.
Thank you!

iOS Strech Animation - Where should I start looking?

How can I achieve a stretch animation look?
Where do I need to start looking? CABasicAnimation does not seem to do the trick. Something like this: is the desired effect:
http://inspirationmobile.tumblr.com/post/112168531484/sidebar-animation-by-jacub-antalik-ramotion-com
There is a lot more than a simple animation in this view.
It is used UIKitDynamics, but the smart thing is that the final effect is composed by the single effects of small invisible UIViews inside that view.
The border is a CAShapeLayer made by a combination of bezier path that interpolates those single views.
Each drawing cicle, the CAShapeLayer path is refreshed based on the position of those views.
You can find more about this effect here.
For such a complicated shape animation look into CAShapeLayer and UIBezierPath. Look at this SO thread that might help you to get started at least.

Random Animation

I'd like to build a random animation of a imageview on iPad. What i manage to build so far is this:
The arrow represents my imageview. it moves to the bounds of its parent view an changes it direction. Actually this is not what i want. Id like to move the view randomly in it's parent view, in curves. And also adjust its heading, like in this figure:
I've no clue how to solve this and in particular how to generate a nice smooth path. Maybe someone has a hint for me.
Brad Larson answers a question that will give you some insight here: How do I translate parabolically?
Choosing random points is pretty easy and when you add them using a keyframe animation and a path, you get the smoothing you're looking for. You would just need to add the points to the path reference.
You add the path to the keyframe animation according to the link above and then add the animation to the UIImagView's layer with:
[[imageView layer] addAnimation:pathAnimation forKey:#"pathAnimation"];
Best regards.
Try out with Bezier curves with following
Drawing bezier curves with my finger in iOS?
and
CGPathReference
You would actually get quite far by just configuring the calculation mode of the key frame animation to be cubic
positionAniamation.calculationMode = kCAAnimationCubic; // or kCAAnimationCubicPaced
That will cause it to construct cubic splines between the points specified in the values array.

How to reshape UIView like rhombus

I'm trying to add a UIView to each side of a cube like the one in this pic:
http://upload.wikimedia.org/wikipedia/commons/0/02/Face_colored_cube.png
Since UIViews are rectangular shaped it's difficult to achieve what I'm trying. All I do by now is to rotate views but it isn't enough.
What's the correct way to achieve that? Any ideas?
Thanks in advance.
You need to do a perspective view transformation.
Have a look at this tutorial
You can also look at this answer by Brad Larson

Prob when rotating an uiimageview

When I am working with uiimageview, I want to rotate it with a small angle, and I did. But, in the border of uiimageview after rotating appears spikes, like a saw. I do not know why and try to fix it but I cant. Please help me.
Couple of options..
1) If you are using Core Graphics functions to rotate you can enable anti alias options
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
2) Add a 1 pixel transparent border to the your image on all 4 sides.
One more thing, there is a technical term to the spikes you saw and it is aliasing. And the techniques to prevent aliasing are called anti aliasing techniques. Hope this helps.
Thanks all you guys :) My friend showed me another way to fix it. I think this way is better than using transparent border trick. He changed an attribute in info plist file, that is "Renders with edge antialisasing", to YES. And everything becomes okay :). I hope it will help someone get a same prob with me :)
Take a UIView as subView and Place UIImageView on subView.
Keep the size of subView and UIImageView Same.
Now, Use "UIViewAnimationTransitionFlipFromRight" or "UIViewAnimationTransitionFlipFromLeft" with Timer.
What you can do easily is to add a 1px transparent border around your image. So if your image is, let's say, 50x50 pixels you need to make it 52x52 such that the outer pixels are transparent. When you will rotate it should look fine now.

Resources