How to prevent UISegmentedControl from scaling segment images on iOS 7

I have UISegmentedControlwith borders 100x42. I created three segments with 26x26 images and 4x42 divider images. three- segmented images should be placed in segments, but they are scaled and, worse, they seem to fit vertically and only decrease horizontally, while losing proportions.

This problem appeared after I switched to Xcode 5 and iOS 7 SDK. Prior to this, segment images were displayed in the correct proportions and in the original size.

I do not use an interface constructor . I tried to manually set the segment sizes and set the segmented control contentModeto UIViewContentModeScaleAspectFillno help.

Is there a way to make it UISegmentedControljust render the images as they are?

+4
source share
2 answers

You can set automatic layout restrictions to correctly define the UISegmentedControl frame. Like this

enter image description here

0
source

I know this is a late answer, but I have the same problem with testing the application for iOS 7.1.

If you install the image in code, it works correctly. Example:

- (void)viewDidLoad {
  [super viewDidLoad];
  [_segmentedControl setImage:[UIImage imageNamed:@"779-users-toolbar"] forSegmentAtIndex:0];
}

In my project, I have a normal image, as well as @ 2x and @ 3x image versions.

I checked the code in 7.1, xcode 6.1.

8.1, , IB, , 7.1, 8.

0

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


All Articles