简体   繁体   English

在 tabItem 中自定义 SF Symbol

[英]Customize SF Symbol within tabItem

I am using SF Symbols to create dots for an image carousel.我正在使用 SF Symbols 为图像轮播创建点。 I would like these dots to be small and white/outline.我希望这些点小而白/轮廓。 So far, I have been able to reduce spacing between the dots.到目前为止,我已经能够减少点之间的间距。 Now, all modifiers have no effect on the symbol's size.现在,所有修饰符都不会影响符号的大小。

            TabView {
                ForEach(shop.photos?[..<3] ?? [], id:\.self) { url in
                    AsyncImage(
                        url: URL(string: url),
                        content: { image in
                            image.resizable()
                                .scaledToFill()
                                .frame(width: 250, height: 250, alignment: .center)
                                .clipped()
                        },
                        placeholder: {
                            ProgressView()
                        }
                    ).tabItem {
                        Image(systemName: "circle") // Also tried with Label("", systemImage: "circle")
                            .renderingMode(.original) // None of these modifiers had any impact
                            .resizable(resizingMode: .stretch)
                            .aspectRatio(contentMode: .fit)
                            .frame(width: 1.0, height: 1.0)
                            .font(.system(size: 100))
                    }
                }
            }.onAppear() {
                let appearance = UITabBarAppearance()

                appearance.stackedItemPositioning = .centered
                appearance.stackedItemWidth = 10

                UITabBar.appearance().standardAppearance = appearance
            }

You can add foreground color to change the color of the icon.您可以添加前景色以更改图标的颜色。

  Image(systemName: "circle") // Also tried with Label("", systemImage: "circle")
                             .renderingMode(.original) // None of these modifiers had any impact
                             .resizable(resizingMode: .stretch)
                             .aspectRatio(contentMode: .fit)
                             .frame(width: 100.0, height: 100.0)
                             .font(.system(size: 100))
                             .foregroundColor(.white)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM