Skip to content

Apps, games and editors for iOS & macOS written in Swift. Projects are based on materials from P. Hudson.

Notifications You must be signed in to change notification settings

vaIerika/SwiftOnSundays

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Swift on Sundays

Repo includes applications, games and editors for iOS & macOS written in Swift. Projects are based on materials from Paul Hudson.

To impove skill of integration and have some fun I will write solutions of each project in UIKit and SwiftUI versions.


Completion status

Projects UIKit SwiftUI
Memory App (iOS) + +
Inner Peace (iPad) + +
to be continued... - -

Inner Peace

Discussed topics:

  • Resizing text due to its length
  • Adding a shadow to the text (+ rendering an image)
  • Sharing the chosen quote
  • Sending notifications

Sending notifications

The same for both frameworks.

Resizing Text View with SwiftUI + shadow

Text resizing and adding a shadow tasks are quite easier with SwiftUI then with UIKit.

Text(textQuote)
    .font(.system(size: 1000))
    .minimumScaleFactor(0.01)
    .shadow(color: .black, radius: 6, x: 0, y: 3)

Issue 1. Representable for UIActivityViewController

SwiftUI library doesn't have its own view for sharing activity yet.

Solution: Use the functionality of the UIActivityViewController with a UIViewControllerRepresentable.


Memory App


Issue 1. Attributes of a String in SwiftUI

SwiftUI's Text view doesn't attributesText 💔. That's why I had to use UIKit's UITextView()

Solution: Thanks to the protocol UIViewRepresentable we can present UI elements from UIKit as views. It is a bridge between two frameworks.

Issue 2. Sizes of the new-born View

A size of the new View made from UIKit cannot be recognized fast and automatically when it is used as a part of the view's body. Specially if it is inside the ScrollView(), it takes not the space it is needed.

Solution: If you need a specific size, just declare it with .frame modifier. However if the size differs and depends on the content, use a @Binding property wrapper for the height of the UIViewType. It is important to assign it in the main thread. And then use its value for a .frame modifier.



Note

Since I am fascinated by SwiftUI and at the same time I understand an influence UIKit, I wrote projects by Paul Hudson in both frameworks . I'd appreciate any features and improvement you have to share. Feel free to reach me out 😊


About

Apps, games and editors for iOS & macOS written in Swift. Projects are based on materials from P. Hudson.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages