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
348
Feb ’21