小编ial*_*fan的帖子

如何在Flutter中制作弧形底部appBar?

自定义应用栏

如何appBar在我的应用程序中绘制自定义形状以使其看起来像图像?

curve appbar clip flutter

6
推荐指数
1
解决办法
9433
查看次数

SwiftUI 更改滚动视图内按钮的背景颜色

我正在尝试根据 isSelected 状态更改按钮的颜色但不起作用

struct Box: Identifiable  {
    var id: Int
    var title: String
    @State var isSelected: Bool
}

struct BoxView: View {
    var box: Box
    var body: some View{
        Button(action: {
            self.box.isSelected.toggle()
        }){
            Text(box.title)
                .foregroundColor(.white)
        }
    .frame(width: 130, height: 50)
        .background(self.box.isSelected ? Color.red : Color.blue)
    .cornerRadius(25)
    .shadow(radius: 10)
    .padding(10)

    }
}
Run Code Online (Sandbox Code Playgroud)

xcode scrollview ios swift swiftui

2
推荐指数
1
解决办法
2295
查看次数

如果小部件是列表的最后一个索引,如何返回它?

如果它是方法中的最后一项,我想重新调整小部件,但我收到错误...尝试调用:call()

 itemList.last()
     ? CircleAvatar(
       backgroundColor: mainColor,
       radius: 15,
       child: Icon(Icons.done),
        )
      : Container()

Run Code Online (Sandbox Code Playgroud)

list dart lastindexof flutter

2
推荐指数
1
解决办法
8450
查看次数

Swiftui foreach 在按钮数组上循环

当按下循环中的一个按钮时,其背景颜色变为红色,当按下另一个按钮时,其颜色也变为红色。但剩下的按钮仍然是红色的,不会再次变成蓝色。如何只将按下的按钮更改为红色,而将其他按钮更改为蓝色?

struct Box: Identifiable  {
    var id: Int
    var title: String
}

struct MainView: View {


    let boxes:[Box] = [
    Box(id: 0, title: "Home"),
    Box(id: 1, title: "Subjects"),
    Box(id: 2, title: "attendence"),
    Box(id: 3, title: "H.W"),
    Box(id: 4, title: "Quizes"),
    Box(id: 5, title: "class schedule"),
    Box(id: 6, title: "Exam Schedule"),
    Box(id: 7, title: "Inbox"),
    Box(id: 8, title: "Evalouation"),
    ]

    @Binding var showMenu: Bool

    var body: some View{
    VStack {
        ScrollView(.horizontal,showsIndicators: false){
                HStack{
                    ForEach(boxes, id: \.id) {
                        box in
                        BoxView(box: box) …
Run Code Online (Sandbox Code Playgroud)

foreach xcode button swift swiftui

1
推荐指数
1
解决办法
7726
查看次数

标签 统计

flutter ×2

swift ×2

swiftui ×2

xcode ×2

appbar ×1

button ×1

clip ×1

curve ×1

dart ×1

foreach ×1

ios ×1

lastindexof ×1

list ×1

scrollview ×1