Post

Replies

Boosts

Views

Activity

How to explain the behavior of ".frame" when placed after ".offset"
According to the documentation of ".offset", The original dimensions of the view aren’t changed by offsetting the contents; in the example below the green border drawn by this view surrounds the original position of the text: Text("Hello, World!")             .border(Color.black)             .offset(x: 10.0, y: 50)             .border(Color.green) IMO, the modifer (ie,.border(Color.green))followed ".offset" should only affect the original view, but not the new view. When add a ".frame" right after the ".offset", I thought it also only affect the original view. However, the original and the new view are both affected. Text("Hello, World!")             .border(Color.black)             .offset(x: 10.0, y: 50)   		.frame(width:50)             .border(Color.green) Further more, if I keep adding another ".frame" right after the first one, only the original view is affected again. Text("Hello, World!")             .border(Color.black)             .offset(x: 10.0, y: 50)             .frame(width:50)             .frame(width:100)             .border(Color.green) What happened under the hood? Thanks in advanced.
0
0
330
Feb ’21
live preview problem
I want to test the code below in live preview, but it seems not to work. In simulator, the button can change the text well, but not in live preview. How to fix it? Thanks in advance. import SwiftUI struct PreviewOnchangeTest: View {     @Binding var toggle: Bool     @State var text = "nice"     var body: some View {         VStack{         Text("\(text)")             .onChange(of: toggle, perform: { value in                 text = toggle.description             })         Button(action: {toggle.toggle()}, label: {             Text("change")         	})         }     } } struct PreviewOnchangeTest_Previews: PreviewProvider {     @State static var toggle = true     static var previews: some View {         PreviewOnchangeTest(toggle: $toggle)     } }
1
0
1.2k
Jan ’21
can't open documentation __update problem
I update my Xcode to the latest version today. After that, I can't access the developer documentation from the Xcode anymore. The error report says: Application Specific Information: Sending windowMenu_showDocumentation: to IDEDocCommandHandler from <NSMenuItem: 0x7f99fa73ee00 Developer Documentation> ProductBuildVersion: 12A7209 ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEPlugins/IDEPlugins-17192/IDEDocViewer/DocumentationNavigator.swift:142 How can i solve the problem? Thanks in advance.
3
0
634
Sep ’20