I'm trying to load image async using AsyncImage - but the results is that the image is very big and covers all the screen.
TabView {
CreateView()
.tabItem {
Image(systemName: "plus.circle")
}
AccountView()
.tabItem {
let imageUrl = LoginManager.shared.profile!.profileImageUrl
ZStack {
AsyncImage(url: URL(string: imageUrl)) { phase in
switch phase {
case .empty:
ProgressView()
case .success(let image):
image.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 56, maxHeight: 56)
case .failure:
Image(systemName: "person.circle")
@unknown default:
// Since the AsyncImagePhase enum isn't frozen,
// we need to add this currently unused fallback
// to handle any new cases that might be added
// in the future:
EmptyView()
}
}
.frame(width: 50, height: 50)
}
.frame(maxWidth: 56, maxHeight: 56)
}
}
Tried to put .frame bounds in every single place but the image is extremely big!
What am I doing wrong?
Thanks for assisting!
I solved this issue by using ZStack. Although it's tricky, but working completely.