UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.