Ios 是否在tintColor和OnIntColor属性上切换自定义图像?

Ios 是否在tintColor和OnIntColor属性上切换自定义图像?,ios,objective-c,ios7,uiswitch,Ios,Objective C,Ios7,Uiswitch,我试图通过设置UISwitch的tintColor和onTintColor属性在UISwitch(在iOS7中)上设置自定义图像,如下面的代码所示 UIImage* onImage = [UIImage imageNamed:@"tutorial-switch-on.png"]; onImage = [onImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageR

我试图通过设置UISwitch的tintColor和onTintColor属性在UISwitch(在iOS7中)上设置自定义图像,如下面的代码所示

    UIImage* onImage = [UIImage imageNamed:@"tutorial-switch-on.png"];
    onImage = [onImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeStretch];

    UIImage* offImage = [UIImage imageNamed:@"tutorial-switch-off.png"];
    offImage = [offImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeStretch];


    [self.mySwitch setOnTintColor:[UIColor colorWithPatternImage:onImage]];
    [self.mySwitch setTintColor:[UIColor colorWithPatternImage:offImage]];
我不知道为什么我的图像没有拉伸。有无

  "resizableImageWithCapInsets: UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeStretch"

我得到了同样的结果,一个平铺的图像。我不明白为什么ResizeableImageWithCapInsets:方法不起作用。如何拉伸图像?或者将它们安装到UISwitch中。

您有没有找到解决方案?我尝试使用imagePattern设置onTint和ThumbTint颜色,但没有成功。不知何故,我将tintColor设置为clearColor,并在开关后面,在同一点上,我放置了一个UIImageView,其中包含我想要用于offImage的图像。