I want to create rotating color fan like this app does(i.e. See the last picture in screenshots there is color stripes). Any body can tell me what should be my good starting point for this. I have already google but not found anything like this might be I am missing something so anybody can point me at good tutorial or sample code or steps for how to achieve this thing.
-
what exactly do you want? do you want just an image like that one or do it programmatically with views and calayers? – guenis Feb 22 '13 at 16:45
-
I want to do it with views and CALayer. Main thing is such animation and rotating color views. So, whether it is image view or view it doesn't matter.If we can achieve with imageview then with little effort we can achieve same thing with view – Iducool Feb 22 '13 at 16:54
1 Answers
Put all your views on top of each other. Set the anchor point of your views to the same lower point of the view. The anchor point is the point used as origin when applying affine transformations to your view (scale, rotate etc). It is a CGPoint where field values range between [0,1]. Default is [0.5, 0.5] the center point of your view. So you will set it to something like
view.layer.anchorPoint = CGPointMake(0.5, 0.9);
//The images you show are not rotated at exactly the same point so you should vary height value a little between 0.8 and 1.0 maybe.
Beware setting anchorPoint translates your view, so be sure to check out the below question:
Changing my CALayer's anchorPoint moves the view
Then set up an affine transform for rotation and apply it to all views in a for/while loop in increasing order:
view.transform = CGAffineTransformMakeRotation(M_PI / 12 * i);
// i is the loop variable. your views will rotate 15, 30, 45 ... degrees respectively

- 8,084
- 8
- 48
- 62

- 2,520
- 2
- 25
- 37
-
Nice answer.I know already this because I have referred the "Rotating Wheel" example of RayWanderlich. Here how that stripe will move based on touch with animation and how to reuse is more important. If you can share your knowledge about it then it would be great – Iducool Feb 23 '13 at 04:20