Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UIScrollView won't really buy you anything in this situation. It won't queue/dequeue things automatically (UITableView will though) and it only responses to horizontal &amp; vertical scrolls. Out of the box, you can't rotate it around an axis.</p> <p>There is really nothing in the UIKit to help you out, you will probably want to start of scratch with a UIView. </p> <p>Use <a href="http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIPanGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UIPanGestureRecognizer" rel="nofollow">UIPanGestureRecognizer</a> (Dragging) and <a href="http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISwipeGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UISwipeGestureRecognizer" rel="nofollow">UISwipeGestureRecognizer</a> to keep track of when your user touches the rotating element. <code>UIRotatationGestureRecognizer</code> probably isn't what you want, because it requires the user to use two fingers.</p> <p>Depending on how complex you are getting with this view, you may be able to get away with just doing: </p> <pre><code>view.transform = CGAffineTransformMakeRotation(someRadian); </code></pre> <p>Calculate the rotation amount (in radians) based on how far x &amp; y the user had drug. Depending on how fancy you want to get, 1 pixel x or y could get you a .1 radian rotation (I'm just guessing, you'll want to play around with it until you get the speed right). If you want to get really fancy and make your user actually arc their finger you'll want to use some trigonometry to translate that into a rotation amount. </p> <p>If it is a swipe, calculate how far &amp; long you want the view to rotate and wrap it in a UIView animation. </p> <p>If you find this not working, you may need to go down to the CALayer, which is only slightly more complex:</p> <pre><code>view.layer.transform = CATransform3DMakeRotation(someRadian, 0, 0, 1); </code></pre> <p>and to animate it you will need to create a CAAnimation:</p> <pre><code>CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; rotate.fromValue = [NSNumber numberWithFloat:0]; rotate.toValue = [NSNumber numberWithFloat:someRadian]; rotate.duration = 2.0; // seconds [view.layer addAnimation:rotate forKey:nil]; // "key" is optional </code></pre> <p><a href="http://www.informit.com/blogs/blog.aspx?uk=Ask-Big-Nerd-Ranch-Rotating-an-iPhone-View-Around-a-Point" rel="nofollow">This</a> might give you more information</p> <p>As for your adding/removing colors, by keeping track of how far the circle has rotated, you should be able to calculate which color swatches you want to see. But, if you are willing to make the concession to a limited number of colors, you could simply layout the UIView with all the colors in Interface Builder, add it to the root view with only the right hand corner visible, and then rotate it as described earlier and not have to worry about this. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload