Categories
SwiftUI

How to Create the Snake Game in SwiftUI

Create the classic snake game in SwiftUI without a grid Enum and Variables We are going to detect the swipe direction and have the snake move in that direction constantly until the direction changes. Let’s first create an enum for the directions: We will have a timer to control the snake’s speed. To make the […]

Categories
SwiftUI

Build a Chat App Interface With SwiftUI

Every app has messaging now. Here’s how you can quickly build messaging into your app Chat Model Let’s start by creating an enum for the bubble positions. Bubbles can be on the right or left side of the screen: Now, we can create our model that stores our messages, bubbles’ positions, and the user input […]

Categories
SwiftUI

Understand Stack Views in SwiftUI

There are three built-in stacking views in SwiftUI; VStack, HStack, and ZStack. All three stacks are of type View. Stacks have alignment and content parameters. VStack & HStack also have a spacing parameter. In SwiftUI, the last parameters can be omitted, the default alignment in the center and the spacing is dynamic when it is […]

Categories
SwiftUI

Introduction To SwiftUI

Functional Programming SwiftUI is a functional programming language that uses the View protocol to create reusable UI components. Views are value types, which means you don’t define classes for them. Struck is read only, you can’t inherit from them. Views are rectangular areas on screens that are used for drawing and multi touches. Create SwiftUI […]