0
问候, 我有UISegmented控制与图像 - 可以设置背景色调。这是通过代码viewDidLoad中添加导航栏:如何在UISegmentedControl中为图像制作图像插图?
UISegmentedControl *myCustomButton = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects:[UIImage imageNamed:@"spiral"],nil]]; [myCustomButton setSegmentedControlStyle:UISegmentedControlStyleBar]; [myCustomButton setTintColor:[UIColor blackColor]]; UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:myCustomButton]; self.navigationItem.rightBarButtonItem = segmentBarItem;
的问题是,在按钮中的图像被拉伸所有它能方式,所以我想用形象的插图,但如何我打电话给他们的代码?
我试过这个: [self.navigationItem.rightBarButtonItem setImageInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
但它没有做任何可见的事情。
我发现在段文本的左侧和右侧添加空格时效果很好。 – titaniumdecoy 2011-05-27 20:39:37