From the course: iPadOS 13 Development Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating views for one platform - iOS Tutorial
From the course: iPadOS 13 Development Essential Training
Creating views for one platform
- [Instructor] If you're developing a cross-platform application, you may have situations where you want one view to display on one platform and another view to display on another. So, to do that, here's one way. So, when you're creating a project using Swift UI, you might have a lot of view files, like this one here. Inside of those view files you can determine which views are displayed in the body. So, we have our text here that says "Hello, World," for example. But what if I wanted this view to have two different bodies, one for Mac and one for other platforms? Well, I could do that by wrapping this in an if statement for the compiler. So if you put a pound sign then if, and then targetEnvironment, and inside of the parentheses you can type macCatalyst, then below that you can do an endif, and above that we'll put an else, and then copy the body, and paste. And then I can change those two text objects to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.