我正在使用背景和分隔线图像来自定义UISegmentedControl
. 但是,分隔图像和段控件的背景图像之间会出现一个空格。
这是显示空格的屏幕截图
这是我用来设置分段图像的代码
UIImage *selectedImage = [[UIImage imageNamed:@"segcontrol_selectround.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
UIImage *unselectedImage = [[UIImage imageNamed:@"segcontrol_unselectround.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
UIImage *leftSelected = [UIImage imageNamed:@"segcontrol_leftselected.png"];
UIImage *rightSelected = [UIImage imageNamed:@"segcontrol_rightselected.png"];
UIImage *neitherSelected = [UIImage imageNamed:@"segcontrol_bothunselected.png"];
[segment setBackgroundImage:unselectedImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segment setBackgroundImage:selectedImage forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[segment setDividerImage:leftSelected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segment setDividerImage:rightSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[segment setDividerImage:neitherSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
我检查了所有的分隔线图像,它们都是相同的宽度并且不包含任何透明像素。
如何从分段控件中删除这些空格?