From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Labels

Labels

- [Instructor] We've seen images in text, but you can combine them together called the label. This combination is especially important for buttons to have both icons and text. There's variations of the label. Well, you can break them into simple and custom. The simple takes a string and either an image or SF symbol. For example, I can add an image to the order pizza stack like this. So let's go up to a bit in the code here and where it says order pizza, I'll put right before that label and you can see the types that you've got there. But I'm just going to put some quotes here and put in cart and then comma and then system image. And you can put in cart here too. I got cart from before and then it compiles and I get a leading icon with the word cart. The second version of the label uses closures for the text and icon. I also want to put the total order next to the cart. I can use the image I created earlier in a formatted text like this. So I'm going to go over here to where this image…

Contents