How can I use SwiftUI as a drawing board for a printer label designer? I want to combine views (or add multiple views to a parent view) for different images, text and barcode etc. (after the user select what they want to design and print).
Currently I have put different views (separate view for image, text, barcode etc) inside an instance of TabView and use the tabItem() modifier for each view. I tried using different stacks (ZStack, HStack) but it does not work.
I also want to create a bounding box for each view/object created and have it resized when the user resize the image/text.
Here is part of the code for the label designer with only text:
var body: some View
{
ZStack(alignment: .center)
{
ZStack(alignment: .topTrailing) //Label Design Area
{
Rectangle()
.opacity(0.3)
.offset(x:0,y:0)
.frame(width: (LabelWidth * mmTOpt), height: (LabelHeight * mmTOpt))
ZStack()
{
TextField("", text: $Text1)
.offset(x:offsetx + location.x , y:offsety + location.y)
.multilineTextAlignment(.center)
.submitLabel(.done) // changed to IOS 15
.font(Font.custom(fontused, size: fontsize))
.disabled(tfdisabled)
.gesture(simpleDrag.simultaneously(with: fingerDrag))
.underline(textunderlined)
.bold(textbold)
.italic(textitalic)
.strikethrough(textstrikethrough)
I tried to combine the image view using HStack with the following code:
HStack(alignment: .center) {
PhotosPicker(selection: $selectedItem, matching: .images, photoLibrary: .shared()) {
Text("Select a photo")
}
…….
Is there any other methods I can use?