在SwiftUI中在列表元素位置内移动

时间:2020-06-17 19:34:03

标签: swiftui swiftui-list

当我单击另一个元素时,我正在尝试移动列表元素的位置

当我单击即会发生

我需要视图向上移动并保持这种状态,而无需用户移动

        VStack{
            VStack{
                Button(action: {
                    self.iconeView.toggle()
                }) {
                    ZStack{
                        self.icone.renderingMode(.original)
                            .frame(width: UIScreen.main.bounds.width * 0.4, height: UIScreen.main.bounds.height * 0.2)
                    }
                }

            }//Photo
                .padding(.bottom, 54)
                .padding(.top, 42)

            List {

                VStack(alignment: .leading){
                    Text("Nome do remédio")
                }//Medicine Name
                .padding(.bottom, 10)

                VStack(alignment: .leading){
                    Text("Quantidade de remédio")
                }// Quantity
                    .padding(.bottom, 50)

                VStack(alignment: .leading){
                    Text("Horario Inicial")

                }//Start time

            }//List


        }//Screen

1 个答案:

答案 0 :(得分:0)

由于您具有预定义的元素数量,因此此处更适合使用class_id而不是const User = sequelize.define('user', { id: { type: DataTypes.UUID, primaryKey: true }, }); const Class = sequelize.define('class', { id: { type: DataTypes.UUID, primaryKey: true }, students: DataTypes.ARRAY({ type: DataTypes.UUID }), }); Class.hasMany(User, { foreignKey: 'class_id' }); User.belongsTo(Class, { foreignKey: 'class_id' }); 。因此解决方案可以如下(使用伪代码)

使用完整的演示代码进行更新。使用Xcode 11.4 / iOS 13.4进行了测试

demo

ScrollView