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