Your First iOS & SwiftUI App: Polishing the App, Episode 9: SFSymbols | raywenderlich.com

SFSymbols is a massive collection of symbols and icons that you can use in your apps. Let’s learn how this works.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28797859-your-first-ios-swiftui-app-polishing-the-app/lessons/9

In this lesson, I had to use .foregroundColor(Color(“DarkTextColor”)) as opposed to “TextColor” because the icon could not be seen with the white background. In the lessons before we defined the color “DarkTextColor” in the Assets.xcassets. not “TextColor”.

Not sure if I did something wrong or missed a step but my code is this:

//
//  RoundedViews.swift
//  Bullseye
//
//  Created by Chuck Condron on 12/8/22.
//

import SwiftUI

struct RoundedImageViewStroked: View {
    var systemName: String
    
    var body: some View {
        Image(systemName: systemName)
            .font(.title)
            .foregroundColor(Color("DarkTextColor"))
            .frame(width: 56.0, height: 56.0)

    }
}

struct RoundedImageViewFilled: View {
    var systemName: String
    
    var body: some View {
        Image(systemName: systemName)
            .font(.title)
            .foregroundColor(Color("DarkTextColor"))
            .frame(width: 56.0, height: 56.0)

    }
}


struct PreviewView: View {
    var body: some View {
        VStack( spacing: 10) {
            RoundedImageViewStroked(systemName: "arrow.counterclockwise")
            RoundedImageViewStroked(systemName: "list.dash")
        }
 
    }
}

struct RoundedViews_Previews: PreviewProvider {
    static var previews: some View {
        PreviewView()
        PreviewView()
            .preferredColorScheme(.dark)
    }
}

it seems to work just perfect in both dark and normal mode previews. Please advise…