我想在视图的过渡上创建一个动画(在视图层次结构中插入/删除它时),并在某些可动画修改器上创建一个不同动画。
在此示例中,.transition
的 easeInOut 动画,.rotationEffect
修饰符的 spring 动画。
预期结果:.easeInOut
动画适用于过渡,.spring
动画适用于旋转
实际结果:.spring
动画也适用于过渡:-(
struct MyView: View {
@State var visible = false
@State var rotated = false
var body: some View {
VStack {
Spacer()
if self.visible {
Rectangle()
.frame(width: 10, height: 50)
.rotationEffect(self.rotated ? .degrees(90) : .zero)
.animation(.spring(response: 0.5, dampingFraction: 0.30, blendDuration: 1))
.transition(.offset(x: -200, y: 0))
.animation(.easeInOut)
}
Spacer()
Button(action: {
self.visible.toggle()
}, label: { Text("[Visible]") })
Button(action: {
self.rotated.toggle()
}, label: { Text("[Rotate]") })
}
.frame(width: 300, height: 300)
}
}
PlaygroundPage.current.setLiveView(MyView())
struct Contents_Previews: PreviewProvider {
static var previews: some View {
MyView()
}
}
答案 0 :(得分:3)
要将version: "3.2"
services:
aggregator:
restart: always
build:
context: .
args:
environement: development
volumes:
- ./:/aggregator
depends_on:
- mongodb
mongodb:
image: mongo
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
动画仅应用于旋转,请将.spring
添加到value: self.rotated
修饰符:
.animation