My Authors
Read all threads
I want to show you just how easy it is to recreate this Control Center widget in SwiftUI with interaction, animations, and all using a Swift Playground.

Thread 👇
Using Swift Playgrounds (on iPad or Mac), let’s make the circle + icon component (using SF Symbols) and add some text beneath it.

We place these together in a VStack (vertical stack) to get them to vertically stack on top of one another.
Next, let’s make a 2x2 grid of the component we just made.

We’ll place two HStacks (horizontal stacks) inside of a single VStack so to do this.
- We’ll adjust the icons + text of the new components we copied
- Introduce a variable called “spacing” (we’ll use this later to control spacing & padding)
- Add a background color to our containing VStack
Let’s introduce a variable called “isExpanded” so that when we tap on our widget it can grow and shrink by hiding the text labels.

To do this, we’ll use an onTapGesture on our VStack to toggle “isExpanded” on and off. We’ll also make each text label visible if expanded.
Next up, animation.

This is as simple as wrapping our “isExpanded” toggle inside of withAnimation. We’ll also adjust our “spacing” variable we introduced earlier to grow or shrink depending on if we’re expanded to give the widget some breathing room.
Let’s make the WiFi button toggle-able, and turn it blue when it’s enabled.

- Introduce a “wifiEnabled” variable
- Wrap our WiFi VStack inside of a Button so that we can toggle wifiEnabled on or off.
- Make the background of the WiFi circle blue if enabled.
Last but not least, let’s speed these animations up by providing some durations to withAnimation
Nice! We’ve recreated a Control Center widget that animates to grow and shrink. We can also turn WiFi on or off without expanding the widget.

This is just a small example of placing the focus on layout and style and letting SwiftUI do the rest automagically ✨
Here’s the code: gist.github.com/jordansinger/3…

Please reach out if I can help clarify anything or with any questions!
Missing some Tweet in this thread? You can try to force a refresh.

Keep Current with Jordan Singer

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!