Post

Replies

Boosts

Views

Activity

Reply to How to call a SwiftUI button by its UUID?
How shall I explain it other than I already did several times? Showing a code would better explain. What do I have to do to let the big orange button do what its label says? All the same. Simply make an Array. You just need more attribute than a single String. import SwiftUI struct TextAttribute { var text: String var foregroundColor: Color var borderColor: Color var borderWidth: CGFloat } struct Test: View { @State var attributes: [TextAttribute] = [ TextAttribute(text: "This is text 1", foregroundColor: .green, borderColor: .black, borderWidth: 1), TextAttribute(text: "This is text 2", foregroundColor: .blue, borderColor: .black, borderWidth: 1), ] var body: some View { VStack { ForEach(0..2) {i in Text(attributes[i].text) .foregroundColor(attributes[i].foregroundColor) .border(attributes[i].borderColor, width: attributes[i].borderWidth) } Button(action: { //Set foregroundColor only of text 1 to purple attributes[0].foregroundColor = .purple //make its border width 3 attributes[0].borderWidth = 3 //the border color only of text 2 to gray attributes[1].borderColor = .gray }, label: { Text("Set foregroundColor only of text 1 to purple, make its border width 3 and set the border color only of text 2 to gray") .font(.system(size: 30)) .foregroundColor(Color.black) .background(Color.orange) }) .padding(.top) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Comma not working
But it doesn't work when decimal in the second operand. Try 0.1 + 0.2, you won't get the right result (at least for me) Thanks, all. Please try commenting out line 122:                                     //operat = Nums.virgola;
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Comma not working
Thanks for your reply. I have tried your code as exactly the same as shown in the opening post of this thread. when I press the decimal point button it should add a decimal point, Run the app = 0 shown Press the decimal point = 0. is shown (a decimal point is actually added) what happens is that when I press the decimal point it doesn't consider the numbers that I write after the decimal point. (Continuing) Press 2 = 0.2 is shown Press X = 0 is shown Press 5 = 5 is shown Press = = 1 is shown So, the calculation is made considering the number after the decimal point. Did you get some different results than this?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Comma not working
Do you know why the comma in this calculator app isn't working: I cannot find any commas (,) in your code. Are you calling the decimal point (.) as comma? And isn't working is the worst phrase to tell what is happening. Can you tell? The steps to reproduce the issue (in detail, one by one) What actually happens? What you expect?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to How to call a SwiftUI button by its UUID?
But what now? You said you have several buttons and you can read each button's UUID. So, seeing how you organized the UUIDs would help writing an example. Everything is in the same view, by the way. Thanks, that can be a good clue. By the way, in the added part, the prototypeButton (in Swift, type names should start with Capital letter) does not have background nor disabled. And I cannot find another button to change the attributes in the body. (Please include the name of the view.) I first thought I could have understood what you had intended, but now all such things are confusing me. Please remember, we readers know nothing about your memory game, nothing about the design of the game, nothing in your mind. If you make some inconsistent explanations, we are just confused and get hard to show something sure. Can you show a little bit better example?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to How to call a SwiftUI button by its UUID?
Thanks for showing the code. You said I can read out each button's UUID, but I cannot find any parts to read out each button's UUID? One more, you wrote I created several buttons, but there is only one button of which the attributes should be modified. I need to change the attributes of the buttons from any place in my code; from "far away" so to say. Please include all the needed thing in the opening post, when you just say it does not work, we readers would spend plenty of time to find what's missing. I think I could understand what you intend far better than nothing, but not enough to write an example. Can you show a little bit better example which includes the codes: to read out each button's UUID several buttons and the far away place where the attributes should be able to changed (Is it in the same View, or somewhere in another View? When you say another View, please show the view hierarchy including the two (or more?) Views.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Landmarks Tutorial. Preview doesn't work
Yes, I've checked all the files, but it looks like I'm missing something.  Thanks for your reply. Unfortunately, Xcode sometimes shows weird behaviors. You may know and already have tried, but restarting Xcode or your Mac, and/or Clean and Re-Build (Produce Clean Build Folder, Cmd-B) would solve some sorts of issues. If you can Run your code, do not use preview would be a temporary workaround. Anyway, many experienced developers are still suffering from Xcode's unkind or weird behavior. Hope you can solve your issue soon and create great apps. Good luck.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21