Categories
SwiftUI

SwiftUI: Markdown support for string variables

struct MarkdownTest: View {
  var text: String = "**Hello** *World*"
  var body: some View {
    VStack {
      Text("**Hello** *World*") // will be rendered with markdown formatting
      Text(text) // will NOT be rendered according to markdown
    }
  }
}

Here how to fix.


      Text(.init(text)) // this renders markdown properly
    

Ref: https://developer.apple.com/forums/thread/683632

Categories
SwiftUI

Find all available images for Image systemName in SwiftUI

These icons are called SF Symbols. There are over 2,400 symbols you can use in iOS 13and later, macOS 11 and later, watchOS 6 and later, and tvOS 13 and later. You can use a symbol everywhere you can use an image.

To browse the full set of symbols, download the SF Symbols app. For more info about SF Symbols check here.

SF Symbols 2 introduces over 750 new symbols and includes:

  • Over 150 preconfigured, multicolor symbols that automatically adapt to vibrancy, accessibility settings, and appearance modes
  • Negative side margins in both standard and custom symbols, giving you greater control over horizontal alignment
  • Localized symbol variants for right-to-left writing systems, as well as script-specific symbols for Arabic, Devanagari, and Hebrew

Usage

UIKit:

let heartImage = UIImage(systemName: "heart.fill")

SwiftUI:

let heartImage = Image(systemName: "heart.fill")

Ref: https://stackoverflow.com/questions/56514998/find-all-available-images-for-imagesystemname-in-swiftui

https://developer.apple.com/sf-symbols/