UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Number Pad

Forums > watchOS

Does anyone know how to have a number pad show up on a text field using SwiftUI. Maybe it doesn’t even have to be a text field. I just need a way to input numbers for a calculation.

I'm currently using a slider but that's not the most efficient way of doing so.



On iOS use .keyboardType(.numberPad) but not sure

TextField("Some Number", text: $someText)

PS there are different Keyboards when you put the . in eg .decimalPad pick which one you want to use.


Did you try:

TextField("Something", text: $property).keyboardType(.decimal)

The string is the sample text that will show, it can be empty, and the text prarmeter is the @State property of your choice.

Not sure about watchOS but that's in SwiftUI.


There is no keyboard on watchOS, only the scatch pad. So enless you want to make your number pad like the Calc App or use a picker


Hi everyone, I made my own SwiftUI keypad for WatchOS! Here is the GitHub link. Hope it helps! Demo on 44mm Watch


Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.