# How To Create a Rotating Wheel Control with UIKit

**URL:** <https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 10:41am UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389 "2016-03-04T10:41:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![funkyboy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/funkyboy/32/109099_2.png) [@funkyboy](https://forums.kodeco.com/u/funkyboy)\
**Post date:** [March 4, 2016, 10:41am UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/1 "2016-03-04T10:41:27Z")

</div>

This is a post whew you will learn how to build custom Rotating Wheel Control with UIKit, written by iOS Tutorial Team member Cesare Rocchi, a UX designer and developer specializing in web and mobile applications. There may be times you’ve downloaded a cool application with a new kind of user interface component, and you’ve […]

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/2953-how-to-create-a-rotating-wheel-control-with-uikit](https://www.raywenderlich.com/2953-how-to-create-a-rotating-wheel-control-with-uikit)

---

<div class="post-metadata">

**Author:** ![pradhaka](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pradhaka/32/62531_2.png) [@pradhaka](https://forums.kodeco.com/u/pradhaka)\
**Post date:** [April 6, 2017, 12:16pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/2 "2017-04-06T12:16:23Z")

</div>

If possible could you please create a tutorial on Rotating Wheel Control with UIKit using Swift 3?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![technified](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@technified](https://forums.kodeco.com/u/technified)\
**Post date:** [May 26, 2017, 11:10pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/3 "2017-05-26T23:10:15Z")

</div>

First of all, thank you sooo much for sharing your code and creating such a wonderful tutorial. I’ve ported it over to C# and am using it in one of my projects.

I have 2 things I am completely stumped on and would love to know to do it. I’ve tried several things but I’m not great at trig :).

1. I’d like to be able to change where the “currentSector” is. For instance, if the imageview that is selected appears in the bottom center of the screen, then it is the currentSector.
2. If I want the position of the actual images not to rotate. I’m going for the ferris wheel effect.

Any help, suggestions or direction would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![funkyboy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/funkyboy/32/109099_2.png) [@funkyboy](https://forums.kodeco.com/u/funkyboy)\
**Post date:** [May 30, 2017, 8:21am UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/4 "2017-05-30T08:21:13Z")

</div>

Hey @technified

1. you need a “new zero” as a starting point, which would be 4.7 radians in the post (or -0.78).  
As for 2), you mean you’d like the frame of the wheel to spin and keep the slices fixed?  
In that case the logic of the stop point is still valid but you’ll apply the rotation to the external circle.

---

<div class="post-metadata">

**Author:** ![technified](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@technified](https://forums.kodeco.com/u/technified)\
**Post date:** [May 30, 2017, 2:56pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/5 "2017-05-30T14:56:34Z")

</div>

Ah! Ok so I need to modify the midpoint when building the sectors. I’ll give that a try!

As for question #2, I’m trying to make a Ferris wheel effect. Based on your response, the container is the outer circle or would I need an additional? I’m at work now but will give your suggestions a try this evening.

Once again, thank you!

---

<div class="post-metadata">

**Author:** ![technified](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@technified](https://forums.kodeco.com/u/technified)\
**Post date:** [June 30, 2017, 5:27pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/6 "2017-06-30T17:27:29Z")

</div>

Ray, I’m so close but there is something I am failing to understand. I have 6 sectors that are 1.04 radians each.  
Let’s say I set my midpoint to 5.20 (that should represent the bottom center sector, I believe). What I’m trying to do is put a check in place where whatever UIview is in the bottom center of the parent container is the only one that is selectable. I have a Gesture recognizer attached to the view that appears in the bottom center of the parent container so that I can open another view. If the bottom center view is not tapped then the control should spin otherwise it should open the view attached to the selected option.

I hope this makes sense and if you need a visual please let me know.  
Thanks for all your help!

---

<div class="post-metadata">

**Author:** ![funkyboy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/funkyboy/32/109099_2.png) [@funkyboy](https://forums.kodeco.com/u/funkyboy)\
**Post date:** [July 4, 2017, 8:30am UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/7 "2017-07-04T08:30:18Z")

</div>

Honestly I didn’t understand what you are trying to achieve ☹

---

<div class="post-metadata">

**Author:** ![technified](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@technified](https://forums.kodeco.com/u/technified)\
**Post date:** [July 4, 2017, 8:46pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/8 "2017-07-04T20:46:24Z")

</div>

My apologies. Maybe this visual will help me explain it better.

On my initial rotation of the container, the Green circle should be the highlighted subview.  
Once I rotate the 2nd time, the red subview should be the highlighted subview. I thought that by setting the midpoint, it would change which subview should be highlighted but that doesn’t seem to be the case.

Also, once I rotate the 2nd time my number 6 is now upside down.

The container is the parent view. Each of the spheres are UIViews that contain an ImageView. The ImageView contains the text.

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/d/9/d91d11544597d5f328d0375ebd2e9dd8b73b0668.png)

---

<div class="post-metadata">

**Author:** ![funkyboy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/funkyboy/32/109099_2.png) [@funkyboy](https://forums.kodeco.com/u/funkyboy)\
**Post date:** [July 5, 2017, 6:31am UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/9 "2017-07-05T06:31:10Z")

</div>

If you want to keep the text oriented correctly you’ll need to compensate for the rotation.  
For example, if you rotate the yellow container by 0.30 you should rotate the labels (and probably also the images) by -0.30

---

<div class="post-metadata">

**Author:** ![atauhen](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/atauhen/32/70148_2.png) [@atauhen](https://forums.kodeco.com/u/atauhen)\
**Post date:** [July 12, 2017, 1:42pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/10 "2017-07-12T13:42:32Z")

</div>

What would be the best way to go further and after user action make forth animation like in the scroll view with slowing down movement according pan gesture velocity?

---

<div class="post-metadata">

**Author:** ![rommex73](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/rommex73/32/81494_2.png) [@rommex73](https://forums.kodeco.com/u/rommex73)\
**Post date:** [August 29, 2017, 3:05pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/11 "2017-08-29T15:05:15Z")

</div>

Thank you so much.  
Just reworked all the code for Swift 4/XCode 9.  
Excellent lesson with lots of guidance.

Feel free to check out Swift 4 code here:

> **[Log in with Atlassian account](https://id.atlassian.com/login?application=bitbucket&continue=https%3A%2F%2Fbitbucket.org%2Faccount%2Fsignin%2F%3Fnext%3D%252Frommex73%252Fsm-rotary-wheel-project.git%26redirectCount%3D1)**
>
> Log in to Jira, Confluence, and all other Atlassian Cloud products here. Not an Atlassian user? Sign up for free.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 29, 2017, 4:36pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/12 "2017-08-29T16:36:29Z")

</div>

This tutorial is more than six months old, so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 29, 2017, 4:36pm UTC](https://forums.kodeco.com/t/how-to-create-a-rotating-wheel-control-with-uikit/6389/13 "2017-08-29T16:36:33Z")

</div>

Closed on August 29, 2017, 4:36pm UTC


