i do this code:
struct TextView: View {
@ObservedObject var service = Service()
@State private var text: String = ""
@FocusState var isInputActive: Bool
var body: some View {
ZStack{
Color(red: 242 / 255, green: 242 / 255, blue: 247 / 255)
.edgesIgnoringSafeArea(.top)
VStack {
Text("QRCode Text")
.multilineTextAlignment(.center)
.font(.system(size: 30, weight: .heavy, design: .default))
.padding(.top, 16.0)
TextField("Enter Text", text: $text)
.textFieldStyle(RoundedBorderTextFieldStyle())
.border(Color.white)
.fixedSize(horizontal: false, vertical: true)
.multilineTextAlignment(.center)
.padding()
.frame(width: 350, height: 80)
.background(Rectangle().fill(Color.white).shadow(radius: 20))
.cornerRadius(30)
.frame(height: 100)
.focused($isInputActive)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button("Done") {
isInputActive = false
}
}
}
Image(uiImage: service.generateQRCode(from: "\(text)"))
.interpolation(.none)
.resizable()
.padding(2.0)
.scaledToFill()
.frame(width: 250, height: 250)
.fixedSize(horizontal: false, vertical: true)
.multilineTextAlignment(.center)
.frame(width: 350, height: 350)
.background(Rectangle().fill(Color.white).shadow(radius: 20))
.cornerRadius(30)
Button("Save QRCode") {
print("save")
}
.padding(.vertical, 10.0)
.padding(.horizontal, 100.0)
.background(Color.blue)
.cornerRadius(20)
.foregroundColor(Color.white)
.frame(height: 100)
Spacer()
}
}
}
}
and when i click on textfield and keyboard up, it up all view, why?