UISegmentedControl Supports Image Aspect Ratio

It is difficult for me to make images on the UISegmentedControl, maintaining their aspect ratio, and not scaling from all sides. Here's what it looks like: UiSegmentedControl supports aspect ratio

Images are 100X100 (with the exception of nr 6 will soon replace), and I want them to maintain aspect ratio.

I tried:

self.segment.contentMode = .ScaleAspectFit
//and:
self.segment.contentMode = UIViewContentMode.Center

Is there a way to target UIImageView in a segment ... that way I can set contentMode..right? Or is there a different approach?

thank

+4
source share
1 answer

, contentMode ScaleAspectFit, :

yourSegmentedControl.setImage(yourImage.resizableImage(withCapInsets: .init(top: 0, left: 10, bottom: 0, right: 10), resizingMode: .stretch), forSegmentAt: 0)

"", "", "" "", . , , !

0

Source: https://habr.com/ru/post/1651177/


All Articles