Upvote:6

Aprove answer
struct TestRisingView: View {

    let screen = UIScreen.main.bounds

    @State var showingView = false
    @State var btFrame: CGRect = .zero

    var body: some View {
        GeometryReader { g in
            ZStack {
                Rectangle().fill(Color.clear)

                self.activatingButton(frame: CGRect(x: 80, y: 30, width: 60, height: 40))
                self.activatingButton(frame: CGRect(x: self.screen.maxX - 80, y: 30, width: 60, height: 40))
                self.activatingButton(frame: CGRect(x: self.screen.maxX - 80, y: self.screen.maxY - 60, width: 60, height: 40))
                self.activatingButton(frame: CGRect(x: 80, y: self.screen.maxY - 60, width: 60, height: 40))

                if self.showingView {
                    self.topView
                        .zIndex(1)
                        .transition(
                            AnyTransition.scale(scale: 0.12).combined(with:
                            AnyTransition.offset(x: self.btFrame.origin.x - g.size.width/2.0,
                                                 y: self.btFrame.origin.y - g.size.height/2.0))
                        )
                }
            }
        }
    }

    func activatingButton(frame: CGRect) -> some View {
        Button(action: {
            withAnimation {
                self.btFrame = frame
                self.showingView.toggle()
            }
        }) {
            Text("Tap")
                .padding()
                .background(Color.yellow)
        }
        .position(frame.origin)
    }

    var topView: some View {
        Rectangle()
            .fill(Color.green)
            .frame(width: 300, height: 400)
    }
}

Upvote:3

ImageCustomScaling(scaleImage: Image(systemName: "cloud.fill"), scaleTo: 5 )

More Answer related to the Same Query

Upvote:2

struct Stackoverflow: View {
    @Namespace var namespace
    @State private var shown: Bool = false

    var body: some View {
        VStack {
            Button {
                shown.toggle()
            } label: {
                Text("Tap Me!\nI'm a red square.")
                    .multilineTextAlignment(.center)
            }
            .background(
                Color.red
                    .matchedGeometryEffect(id: "1", in: namespace, properties: .frame))
        
            Spacer()
            if shown {
                Color.clear
                    .aspectRatio(contentMode: .fit)
                    .matchedGeometryEffect(id: "1", in: namespace, properties: .size)
                    .border(Color.gray)
            }
            Spacer()
        }
        .animation(.easeInOut(duration: 1))
    }
}

struct Stackoverflow_Previews: PreviewProvider {
    static var previews: some View {
        Stackoverflow()
    }
}

Credit Goes to: stackoverflow.com

Related question with same questions but different answers