我正在尝试为我的一个应用程序创建WidgetKit扩展。 我想要一个顶部对齐的标签和一些动态内容。
问题在于所有内容都居中。 我希望标签在顶部,容器应填满其余空间。在该容器中放有物品(也没有居中,从顶部开始)。
这是我的代码:
struct WidgetView : View
{
var data: DataProvider.Entry
var body: some View
{
Text("Test")
.font(Font.system(size: 14.0, weight: .medium, design: .default))
.fontWeight(.semibold)
.background(Color.white)
.foregroundColor(Color.red)
.padding(.top, 8.0)
ForEach(0 ..< 2, id: \.self)
{
_ in
Text("This is just some text")
}
}
}
这将导致以下视图:
我尝试添加一个ScrollView
和一个LazyVStack
。现在看起来就像我想要的样子,但是有一个红色圆圈(在WidgetKit
中可能不允许?):
这可能吗?这是我第一次与SwiftUI
接触。
答案 0 :(得分:2)
使用awk ' ##Starting awk program from here.
FNR==NR{ ##Checking condition FNR==NR which will be TRUE when Input_file absolute_broad_major_cn is being read.
a[FNR]=$0 ##Creating array a with index FNR and having value as current line here.
next ##next will skip all further statements from here.
}
{
print ($0~/[a-zA-Z]/ && a[FNR]~/[a-zA-Z]/?"NA":a[FNR]+$0) ##Printing either addition of current line with array a value or print NA in case any alphabate is found either in array value OR in current line.
}
' absolute_broad_major_cn absolute_broad_minor_cn ##Mentioning Input_file names here.
,底部带有分隔符
VStack