xcode 我有2个错误表达式列表中预期的表达式和预期的')',因为我是swiftUI的初学者,我找不到错误

ruarlubt  于 2022-12-14  发布在  Swift
关注(0)|答案(1)|浏览(112)

您好我正在udemy网站上参加swiftUI培训以学习基础知识今天我正在制作一个杂志应用程序,我遇到了一个错误Expected expression and the following Expected ')' in expression list作为一个初学者我不知道如何解决它,如果您能确切地告诉我为什么会出现此错误
我谢谢你

import SwiftUI

struct ContentView: View {
    // MARK: - PROPERTY
    
    @State private var isAnimating: Bool = false
    @State private var imageScale:  CGFloat = 1
    @State private var imageOffset: CGSize = .zero
    
    // MARK: - FUNCTION
    
    func resetImageState() {
        return withAnimation(.spring()) {
            imageScale = 1
            imageOffset = .zero
            
        }
    }
    
    // MARK: - CONTENT
    
    var body: some View {
        NavigationView {
            ZStack{
                // MARK - PAGE IMAGE
                Image("magazine-front-cover")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .cornerRadius(10)
                    .padding()
                    .shadow(color: .black.opacity(0.2), radius:12, x: 2, y: 2)
                    .opacity(isAnimating ? 1 : 0)
                    .offset(x: imageOffset.width, y: imageOffset.height)                    .scaleEffect(imageScale)
                // MARK - 1 TAP Gesture
                    .onTapGesture(count: 2, perform: {
                        if imageScale == 1 {
                            withAnimation(.spring()) {
                                imageScale = 5
                            }
                        } else {
                            resetImageState()
                        }
                    })
                // MARK - 2. DRAG GESTURE
                    .gesture(
                        DragGesture ()
                            .onChanged { value in
                                withAnimation(.linear(duration: 1)) {
                                    imageOffset = value.translation
                                }
                            }
                            .onEnded { _ in
                                if imageScale <= 1 {
                                    resetImageState()
                                }
                            }
                    )
            } // ZSTACK
            .navigationTitle("Pinch & Zoom")
            .navigationBarTitleDisplayMode(.inline)
            .onAppear(perform: {
                withAnimation(.linear(duration: 1)) {
                    isAnimating = true
                }
            })
            // MARK: - INFO PANEL
            .overlay(
                InfoPanel(scale: imageScale, offset: imageOffset)
                    .padding(.horizontal)
                    .padding(.top, -60)
                    , alignment: .top
            )
        // MARK: - CONTROLS
        .overlay(
            Group {
                HStack {
            }
                .padding(.bottom, 30)
                , alignment: .bottom
                )
            } //: NAVIGATION
                .navigationViewStyle(.stack)
            }
        }
    
    
    
    // MARK - PREVIEW
    
    
    struct ContentView_Previews: PreviewProvider {
        static var previews: some View {
            ContentView()
                .previewDevice("iPhone 13")
        }
    }

我不知道如何解决这个问题

bvhaajcl

bvhaajcl1#

您还有一个没有右花括号的Group {。
代码的这一部分:

// MARK: - CONTROLS
    .overlay(
        Group {
            HStack {
        }
            .padding(.bottom, 30)
            , alignment: .bottom
            )

应道:

// MARK: - CONTROLS
    .overlay(
        HStack {
        }
        .padding(.bottom, 30)
        , alignment: .bottom
        )

相关问题