English 中文(简体)
SwipeAction的图像色
原标题:Set image color in SwipeAction

I m 试图在swipeAction中校对icon的颜色。

            Button {
                print("Hello")
            } label: {
                Label(
                    title: {},
                    icon: {
                        Image(systemName: "checkmark")
                            .foregroundColor(.purple) // It makes checkmark red
                    }
                )
            }

            if #available(iOS 15.0, *) {
                Text("Text").swipeActions {
                    Button {
                        print("Hello")
                    } label: {
                        Label(
                            title: {},
                            icon: {
                                Image(systemName: "checkmark")
                                    .foregroundColor(.purple) // It doesn t change anything
                            }
                        )
                    }
                }
            }
问题回答

一种血清行动有其自身的束缚,被系统采用。 根据文件:

For labels or images that appear in swipe actions, SwiftUI automatically applies the fill symbol variant

可通过添加<代码>tint( modifier而增加。

Text("Text").swipeActions {
    Button {
        print("Hello")
    } label: {
        Label("Choose", systemImage: "checkmark")
    }
    .tint(.green)
}

“Showing


Note: The color red is used by default for destructive actions (like delete) and should be avoided for non-destructive actions. If your action is destructive, use Button(role: .destructive) and the system will color it red if you don’t apply .tint().

Check the documentation for more information about swipeActions.

这里是我如何做的,但这是一个工作:

您可使用<代码>UIImage,而不是Image ,编号为always/code>,并改成Image。 以下是基本法典的例子:

 Image(uiImage: UIImage(named:"your_image")!.withTintColor(.purple, renderingMode: .alwaysOriginal))

P.S.公司还将与来自你的棕榈树的颜色合作,这些颜色可能支持照明/沥滤转换等。

EDIT:我使用上述代码而不是拉贝尔





相关问题
SwiftUI: How do I position a button x points above a sheet?

I am trying to recreate a Maps-style UI with a persistent bottom sheet and controls fixed above. Apple Maps UI with controls above ☝️ Example here, the "Look Around" binoculars button and ...

BraintreeDropIn deprecated functions error

I m getting this error on the latest release of BraintreeDropIn, I really don t get it since based on the patch notes, this should ve been addressed already, I have already tried cleaning derived data,...

how to limit zoom level in map swift ui?

how to limit zoom level in map swift ui i have map and need to make zoom level limited Map(coordinateRegion: $region,annotationItems: viewModel.nearbyGyms) { item in ...

UIImageView - How to get the file name of the image assigned?

Is it possible to read the name of an UIImageView s UIImage that s presently stored in the UIImageView? I was hoping you could do something kind of like this, but haven t figured it out. NSString *...