'How to get default system size of symbol image in UIListContentConfiguration?

When using UIListContentConfiguration, if you provide an SF Symbol image, the system decides how to size it based on your dynamic type text size. reservedLayoutSize documentation states: "Symbol images will be centered inside a predefined reservedLayoutSize that is scaled with the content size category." Also note with Mac Catalyst the image size is determined by your setting in System Preferences > General > Sidebar icon size.

In my app I want to create a sidebar with cells like the Photos app - an album cell has a photo for the image rather than a symbol. To do this, I need to know what size to make the image to ensure it's the same size as symbols in other cells, since the size of the cell's image view is determined by the size of the image you provide. "Non-symbol images will use a reservedLayoutSize equal to the actual size of the displayed image."

How do you get the predefined system reserved layout size?

UIListContentConfiguration.ImageProperties.standardDimension sounded promising but this is just a constant that informs the system to use its default size, rather than exposing that size - its value is -1.7976931348623157e+308.

contentConfiguration.imageProperties.reservedLayoutSize is CGSize.zero by default which means the default size is used. So how do we get that size?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source