![]() ![]() We set the foreground color of the text using foregroundColor(), but the background color using just background().There are two things you’ll notice there: For example, we could give our text a white foreground color and a blue background color like this: Text("Hello, world!") ![]() You can also control the background color of the text by adding another modifier. That will give the text a large font and a blue color. There are lots of these built right in to SwiftUI, and you’ll often find yourself using several at once to get exactly the right effect.įor example, try changing your text to include these modifiers below: Text("Hello, world!") We can customize the way our text looks by adding modifiers. We’re going to be writing a lot more code in there over the course of this tutorial, but first I want to spend a few minutes just noodling around with the basics so you have a better grasp of what’s going on. Finally, it says the UI we want to show is the text “Hello, world!”.That means our ContentView will show other pieces of UI inside. It says the body of this view – the thing that’s actually shown on the screen – will return some kind of SwiftUI view.You’ll create lots of views in your apps, but each one needs its own unique name. It creates a new piece of UI, known as a view in SwiftUI, that is called ContentView.Swift is the programming language we use to build our apps, but SwiftUI is a set of tools that gives us buttons, images, and other common user interface elements. It tells Swift to bring in the SwiftUI framework.I expect the starter code will change over time, but that’s okay because I want you to delete almost all of it – leave only this behind: import SwiftUIĪs you delete parts, you’ll see the preview on the right change immediately – it really is live, and later on you’ll see it’s interactive too. Go ahead and tap your new playground to open it for editing, and you’ll see Playgrounds splits into two parts: on the left is some simple Swift code to get us started, and on the right is a live preview that shows your actual code running. This will be called My App by default, and it will be given a random icon – I’ll show you how to change those later. To get started, press the “App” button under “Get a Playground” to create a new project. Sponsor Hacking with Swift and reach the world's largest Swift community! First steps Take advantage of this top-notch developer experience, get started for free today! The Stream iOS Chat SDK is highly flexible, customizable, and crazy optimized for performance. SPONSORED Stream makes Chat messaging quick and easy! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |