ya, I was able to finally find that %.2f on stack overflow.Took me several hours, and I was extremely frustrated with it at that point.Thanks for the help.
Post not yet marked as solved
Ok,realize the mistake in the above code.However, still doesn't work.I get the infamous can't convert int to cgfloat error.Code should be down in the lable section:var body: some View { VStack{ Button(action: { if (self.image == nil) { self.showingImagePicker.toggle() } else { print("Image Selected") //New_more_other code here } }) { if (image == nil) { VStack { Image(systemName: "square.and.arrow.down.fill") .resizable() .frame(width: 150, height: 150) Text("No Image specified\n Select Image") } } else { Image(uiImage: image) .resizable() .frame(width: 150, height: 150) } } }.sheet(isPresented: $showingImagePicker, content: { ImagePicker.shared.view }).onReceive(ImagePicker.shared.$image) { image in self.image = image } }ANY help would be appreciated as I can not tell what I'm doing wrong here.
GOT IT! Finally!Text("\(PercentageValue, specifier: "%.2f")")Suggestion is have things like specifier, come up in the drop down/type ahead stuff.
Thanks for the suggestion and help.Really do appreciate it as this has gotten extremely frustrating compared to using storyboards.I did figure it out. I used the example from youtube:https://www.youtube.com/watch?v=bqr5NidImk0and that seemed to work on my phone (still something wrong with the simulator.)I'm now on to the point where I'm trying to share data bewtween the 2 views...needless to say this is another very NEGATIVE experianece. In story board I could get this whole app done in an hour.now I'm fighting with the most basic of things like global variables not working or printing or updating correctly.to be quite blunt, I think swift UI is straight garbage. and it's a good thing for the people that developed this that Steve Jobs isn't around anymore. Otherwise they would get fired for incompetence (and rightfully so). I and customers don't have time (or the money to pay for that time) to fight with things and deal with 50 steps for something that should take 1 step. Either way, sorry to vent at you and I do appreciate your suggestion and help.
All,Thank you to all for your suggestions, help and responses!I went with Claude31's answer as the correct one as that got me past the hurdle.Managed to figure this out and why it wasn't working.An image captured from the camera session and not saved, can not be updated. I think it's because it doesn't know how to handle the image as it doesn't know the type of image (i.e. .png, .jpg. gif, etc.). So I created an image with a clear or blank background in paint and added the words to that.I then take the captured camera image save it into a variable, and apply the image with the text saved in the assets folder and apply that as the top layer. Here's the code: let bottomImage = CameraImageView.image var topImage = UIImage(named: "HelloWorld.png") let size = CGSize(width: 242, height: 243) UIGraphicsBeginImageContext(size) let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height) bottomImage!.draw(in: areaSize) topImage!.draw(in: areaSize, blendMode: CGBlendMode(rawValue: 0)!, alpha: 0.8) //the constant below is what takes the 2 images from the context and merges them into 1 new image let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()! //set the combined image into the empty Imageview variable, and then display it ImageViewEmpty.image = newImage UIGraphicsEndImageContext() ImageViewEmpty.isHidden = false
ok. I figured out that there are a couple ways to add text to an image. and they do work provided 1 thing:the image is saved in the attributes folder.I'm taking the image from the camera capture session.So have Camera Capture session. Capture the image, save it into a UIImageView field.Then try and add the text to that UIImageView field.It seems like it won't add the text.Works great if it's a pre-saved image in the attributes folder of the project or pulled from the photo-library.but it won't update the image in UIImageView field that is not saved someplace else.I've tried all the suggestions above nothing seems to work.Beginnning to think this is a bug with IOS 11.4.
Thanks Quincey for the insights.Yes I get back the image I started with, but no text shown on it.So it's like I press the button and it does nothing.In the second one I did get the text on there but it was extremely small (like a few pixels in size.)I did print the size, which is where I came up with those numbers for the UIImageview.image.size.let label = UILabel(frame: CGRect(origin: CGPoint(x: 20, y: 20), size: CGSize(width: 3024.0, height: 4032.0)when I started playing around with those sizes, it did seem to zoom in on the text a little but it zoomed in on the whole picture.Like it put the text on it really small, and then zoomed in on that part of the image, which is incorrect as well.either way thanks for the help and advice.
I think you go the right idea. Combine Image A with Image B to create an Image C. I want to display Image C on the phone, in which then other actions can be taken.I don't want to "save" it to the photo library or anything like that.I'll give that a shot.thanks for the help!
Post not yet marked as solved
yes,I am now having the same issue.Is there a solve/fix to get the original question answered. about having the app rotate 180 degrees?