0

我想自定义我的应用程序的 UISegmentControl,我使用了以下代码:

UIImage *segmentSelected = [UIImage imageNamed:@"segcontrol_sel.png"];
UIImage *segmentUnselected = [UIImage imageNamed:@"segcontrol_uns.png"];
UIImage *segmentSelectedUnselected = [UIImage imageNamed:@"segcontrol_sel-uns.png"];
UIImage *segUnselectedSelected = [UIImage imageNamed:@"segcontrol_uns-sel.png"];
UIImage *segmentUnselectedUnselected = [UIImage imageNamed:@"segcontrol_uns-uns.png"];

[[UISegmentedControl appearance] setBackgroundImage:segmentUnselected
                                               forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected
                                               forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

[[UISegmentedControl appearance] setDividerImage:segmentUnselectedUnselected
                                 forLeftSegmentState:UIControlStateNormal
                                   rightSegmentState:UIControlStateNormal
                                          barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setDividerImage:segmentSelectedUnselected
                                 forLeftSegmentState:UIControlStateSelected
                                   rightSegmentState:UIControlStateNormal
                                          barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance]
     setDividerImage:segUnselectedSelected
     forLeftSegmentState:UIControlStateNormal
     rightSegmentState:UIControlStateSelected
     barMetrics:UIBarMetricsDefault];

我从我的应用程序中获得了以下图片

第一张图片

第二张图片

第三张图片

第四张图片

我使用了几种方法来纠正问题,例如 CGImages 和 Resizable Images,但没有一个有效!问题是什么,我应该如何解决?

4

1 回答 1

0

我想你应该看看下面的链接

http://idevrecipes.com/2010/12/13/wooduinavigation/

这里也有一个演示代码

https://github.com/xhan/PlutoLand

于 2013-10-10T07:51:53.570 回答