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:
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.
Further more, if I keep adding another ".frame" right after the first one, only the original view is affected again.
What happened under the hood? Thanks in advanced.
Code Block 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.
Code Block 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.
Code Block 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.