NavigationStack {
TabView(selection: $selection) {
HomeView()
.tabItem {
Image(systemName: "rectangle.grid.1x2.fill")
.padding(.top, 8)
}
.tag(0)
ChatsView()
.tabItem {
Image(systemName: "message")
.padding(.top, 8)
}
.tag(1)
}
.accentColor(.black)
}
I want to use an image from assets instead of Image(systemName: "message")
. When I write Image("myImage")
, it does load the image from the assets, but it’s not the same size, it’s way too large. So I tried Image("myImage").resizable().frame(width: 20, height: 20)
. But the resizing just does not work here, the size stays the same, I don’t know why. So the next thing I tried is just scaling down the asset image. This does work, but the image displayed is very pixelated with this approach. So not an option either.
How can I do this?
2
Answers
I had to adjust NexusUA's answer a little to make it work:
Try this: