Reputation: 262
Would really appreciate it if anyone knows how to implement it or ideas on how to do it.
Upvotes: 12
Views: 4766
Reputation: 206
use this approach
NavigationView{
VStack(alignment: .leading) {
ScrollView(.vertical){
ForEach(list, id: \.self) { item in
Text(item).font(.title).padding()
}
}
Spacer()
}
.toolbar {
ToolbarItem(placement: .principal) {
Text("write something for title")
.font(.heavy)
}
ToolbarItem(placement: .navigationBarTrailing) {
Image("image").resizable()
.scaledToFit()
.frame(width: 100, height: 50, alignment: .trailing)
}
}
}
}
}
Upvotes: 0
Reputation: 13625
I can only answer for the first part, which is - How to set an image with in the title :
(in the navigationbar)
struct ContentView: View {
var body: some View {
let array = ["thing 1", "thing 2", "thing 3", "others"]
NavigationView{
VStack(alignment: .leading) {
ScrollView(.vertical){
ForEach(array, id: \.self) { item in
Text(item).font(.title).padding()
}
}
Spacer()
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Text("Title")
.font(.title)
}
ToolbarItem(placement: .navigationBarTrailing) {
Image(Constants.logoImage).resizable()
.scaledToFit()
.frame(width: 100, height: 50, alignment: .trailing)
}
}
}
}
}
hope it helps!
maybe I'll add here the animation as well in the future if I'll get into it.
Upvotes: -1