在uisegmentControl段之间留有1px空间。我可以删除这个空间! 在ios6中它看起来很好但在iOS7看起来很奇怪
NSArray *itemArray = [NSArray arrayWithObjects: @"By Date",@"By Name", nil];
NSLog(@"ios6");
if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)]) {
segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:[[self resizeImage:[UIImage imageNamed:@"seg_se_r1.png"] xOrigin:150 yOrigin:30]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],[[self resizeImage:[UIImage imageNamed:@"seg_un_l1.png"] xOrigin:150 yOrigin:30]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],nil]];
} else {
segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:[self resizeImage:[UIImage imageNamed:@"seg_se_r1.png"] xOrigin:150 yOrigin:30],[self resizeImage:[UIImage imageNamed:@"seg_un_l1.png"] xOrigin:150 yOrigin:30],nil]];
}
segmentedControl.selectedSegmentIndex=0;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.backgroundColor=[UIColor clearColor];
[segmentedControl setFrame:CGRectMake(10, 10 , 300, 30)];
[segmentedControl addTarget:self
action:@selector(pickOneSegment:)
forControlEvents:UIControlEventValueChanged];
[self.viewSegmentControl addSubview:segmentedControl];
答案 0 :(得分:2)
尝试删除分段分割器
[self.segmentedControl setDividerImage:[UIImage new]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateSelected
barMetrics:UIBarMetricsDefault];
请注意,您需要删除左/右段状态的不同组合的分隔符。