【发布时间】:2019-01-14 12:01:43
【问题描述】:
我有带有图像的 UISegmented 控件 - 以便能够设置背景色调。这是通过viewDidLoad中的代码添加到导航栏的:
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)];
但它不会做任何可见的事情。
【问题讨论】:
-
我发现在段文本的左右添加空格就可以了。
标签: iphone cocoa-touch ios uisegmentedcontrol