We’ve arrived at day 65 of the 100 Days of SwiftUI! Over the past few days, we’ve learned the most important new pieces of code to ensure we can create the Instafilter app. That means that we’ll start with the implementation of the app today! As these apps get bigger and bigger the deeper we dive into the course, I’ll be referring to Paul’s article’s instead of copy-pasting my code here, so that everyone has a clear understanding of every part of the code that’s being written in SwiftUI. Let’s dive in!
Building our basic UI
The first step in our project is to build the basic user interface, which for this app will be:
- A
NavigationView
so we can show our app’s name at the top. - A large gray box saying “Tap to select a picture”, over which we’ll place their imported picture.
- An “Intensity” slider that will affect how strongly we apply our Core Image filters, stored as a value from 0.0 to 1.0.
- A “Save” button to write out the modified image to the user’s photo library.
We’ve already built quite a few user interfaces now, so I decided to try working out one myself before watching Paul’s video. It went pretty well and while I did have to look up a lot of things, that’s part of the job and should help these things sink in. I’d encourage everyone to do the same if they have the time: try thinking about what the app should look like and try to build the UI yourself. It’s just the design, not the functionality.
Importing an image into SwiftUI using PHPickerViewController
We’ve already seen how to import an image from the user’s gallery during the previous two days, so we can recycle most of the code from there. The new bits are explained as well of course.
Basic image filtering using Core Image in SwiftUI
With the user being able to now import an image of their choice, it’s time to move on by putting Apple’s Core Image framework to work and letting users apply filters to their images.
Wrap up
And that’s it for day 65 and the first implementation phase of the Instafilter app! Tomorrow, we’ll be looking to complete the implementation and have yet another SwiftUI project under our belt. For now, it’s time to recharge and get ready. See you tomorrow!
100 Days of SwiftUI – Day 65