我有以下代码,根据import numpy as np
import pandas as pd
import xlrd
from pandas import Series, DataFrame
df = pd.read_excel ('C:/Data.xlsx', sheet_name = 'Sheet1',
usecols = ['PaymentType', 'Money', 'Date'])
df['Date'] = pd.to_datetime(df['Date'])
df = df.pivot_table(index = ['Date'],
columns = ['PaymentType']).fillna(0)
df = pd.merge_asof(df['Money', 'fee'], df['Money', 'rentPay'], on = 'Date', tolerance =
pd.Timedelta('2s'))
#df.to_excel("Finale123.xlsx")
print(df)
部分显示或隐藏Test
视图。我可以将Binding<Bool>
调用包装在testVisible.toggle()
中,但是,理想情况下,我想确保withAnimation
绑定始终保持动画状态,即使在没有visible
的情况下也是如此。我该如何确保只要更改withAnimation
绑定,该更改就会生效?
visible
答案 0 :(得分:1)
在.animation()
视图中添加Text
修饰符:
struct Test: View {
@Binding var visible: Bool
var body: some View {
Text("Test")
.opacity(visible ? 0.5 : 0)
.animation(.linear(duration: 0.5))
}
}