HomeiOS Developmentios - Find out how to construct and name a operate inside...

ios – Find out how to construct and name a operate inside onAppear modifier once we wish to implement inside it a for with stride to be able to present SFSymbols in SwiftUI


I’ve applied in SwiftUI the next code:

import SwiftUI

struct onAppearmodifier: View {
    
    @State var mytext: String = "Begin"

    
    let symbols: [String] = ["globe", "heart.fill","house.fill"]
    var physique: some View {
     
        NavigationView {
            ScrollView {
                ForEach(0..<200) { _ in
                     Rectangle()
                        .body(width: 200, peak: 200, alignment: .heart)
                        .padding()
                        .onAppear {
                            
                            //name the operate that I wish to construct
                            
                        }
                }
            }
            .onAppear {
                
                mytext = "Tremendous"
            }
            
        }
        
        
    }

And I wish to construct a operate utilizing stride to point out on canvas each every rectangle an SFSymbolthat I’ve declared above with interval three, and I wish to name this operate inside onAppear() modifier for a particular variety of rectangles. My thought is to implement a operate of a sure sort and to make use of the next block if I’m proper

 
           for index in stride(from: 0, to: symbols.rely, by: 3) {
               let symbolGroup = Group {
                   Picture(systemName: symbols[index])
                   Picture(systemName: symbols[index + 1])
                   Picture(systemName: symbols[index + 2])

However I do not know the best way to code it after varied tentatives. I’m caught. Any assist or different suggestion will likely be appreciated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments