LAST CHANCE: Save 50% on all my Swift books and bundles! >>

SwiftUI as a drawing board for printer label designer

Forums > SwiftUI

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?

1      

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.