Personalización de botones
Aplique estilos de botones integrados y apariencias personalizadas.
Personalización de botones es una lección gratuita de SwiftUI Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de SwiftUI Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de SwiftUI Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Default Looks Are Fine
SwiftUI gives every button a sensible default style for the platform. But you can reshape its look in seconds with a single modifier. 🎨
The buttonStyle Modifier
Apply a built-in look with the buttonStyle modifier. It changes the whole appearance without you touching the label or action.
Button("Save") { save() }
.buttonStyle(.bordered)Bordered for Soft Buttons
The .bordered style draws a soft, tinted capsule around your label. It is great for secondary actions that should look calm.
Button("Cancel") { dismiss() }
.buttonStyle(.bordered)Prominent for the Main Action
Use .borderedProminent to make the primary action pop with a filled background. Reserve it for the one button that matters most.
Button("Continue") { next() }
.buttonStyle(.borderedProminent)Tinting a Button
Set the accent color of a styled button with the tint modifier. It changes the fill or border to match your brand.
Button("Delete") { remove() }
.buttonStyle(.borderedProminent)
.tint(.red)Controlling Size
The controlSize modifier scales a button between mini, small, regular, and large, so it fits the importance of the action.
Button("Go") { go() }
.buttonStyle(.bordered)
.controlSize(.large)Rounding the Corners
Want a different shape? Pair a style with buttonBorderShape to switch between capsule, rounded rectangle, and more.
Button("Join") { join() }
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)Styling the Label Yourself
For full control, style the label view directly with padding, background, and color, just like any other SwiftUI view.
Button("Buy") { buy() }
.padding()
.background(.blue)
.foregroundStyle(.white)Order of Modifiers
Modifier order matters. Padding before background gives roomy color; background before padding leaves an outer margin instead.
Plain and Borderless
For a text-only look with no chrome, reach for the .plain style. It strips decoration so only your label shows.
Button("Skip") { skip() }
.buttonStyle(.plain)Keep It Consistent
Pick a few styles and reuse them across your app. Consistency helps people instantly know what is tappable and what is primary.
Quick Check
Time to test your styling instincts.
Recap
Great job! Use buttonStyle for built-in looks, tint and controlSize to refine them, or style the label directly for full control. 🎨
Preguntas frecuentes
¿La lección «Personalización de botones» es gratis?
Sí — el texto completo de «Personalización de botones» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de SwiftUI Academy, actualiza a CoddyKit PRO. El curso de SwiftUI Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Personalización de botones»?
Aplique estilos de botones integrados y apariencias personalizadas. Practicas SwiftUI Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar SwiftUI Academy?
No se requiere experiencia previa. SwiftUI Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Personalización de botones»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de SwiftUI Academy?
Sí. Cada lección de SwiftUI Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Creación de un botón pulsable
- Personalización de botones
- Ejecución de código al pulsar
- Desactivar y activar botones