Text Scroll using SwiftUI

Like Star Wars? Done!

Image for post
Image for post
Photo by Daniel Cheung on Unsplash

Imagine that you want to create a scrolling view Star-Wars style. Well, Imagine no longer!

Difficulty: **Beginner** | Easy | Normal | Challenging<br/>

This article has been developed using Xcode 11.5, and Swift 5.2.4


The example

This example is a nice one about how to scroll text up the screen in SwiftUI using instance methods on the Text struct.

Image for post
Image for post

To find out the height of the device I used GeometryReader which is wrapped around the Text view.

Let us see the code, let us see the code. Ok: here it is.

Image for post
Image for post
Click for Gist


Look, this text scroll does not work perfectly. However, this is an interesting tutorial exploring how to lay out Text and change the properties of the text in Swift that can be expanded into your SwiftUI projects.

The full code is hosted on GitHub

Have fun!

If you’ve any questions, comments or suggestions please hit me up on Twitter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store