Is the any ways to set image width and height sizes in swift ui. I found frame method but that is not what I want to.
Here is my swift file.
import SwiftUI
struct HeaderBar: View {
var body: some View {
VStack(alignment: .center, spacing: 0.0) {
HStack(alignment: .center) {
Spacer()
Image("jojologo-yellow")
.frame(width: 30.0, height: 30.0) //that is not the solution to change image size
.padding()
Spacer()
}
.background(Color.orange)
Spacer()
}
}
}
struct HeaderBar_Previews: PreviewProvider {
static var previews: some View {
HeaderBar()
}
}
That would be great if I could use resize method in Image. For example
Image("jojologo-yellow").size(width: 30.0, height: 30.0)
So, my question is "Is there any ways to resize on image in swift ui
Maybe Image("jojologo-yellow").resizable().frame(width: 30.0, height: 30.0) is what you are looking for?
Add .resizable() modifier to your code
Image("yourImageName")
.resizable()
.scaledToFill() // add if you need
.frame(width: 30.0, height: 30.0) // as per your requirement
.clipped()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With