本文介绍了正确定制uiswitch图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS 6应用程序中有一个UISwitch,可以自定义打开和关闭图像。

I have an UISwitch in my iOS 6 app, that's on and off image is customised.

self.testSwitch.onImage = [UIImage imageNamed:@"on"]; 
self.testSwitch.offImage = [UIImage imageNamed:@"off"];

我为此目的使用77点宽和22点高的图像(视网膜154x44),因为它在文档中说明。但是我的图像不适合我的uiswitch,它似乎很难看,默认样式隐藏了我的图像,就像附加图像一样。

I use 77 points wide and 22 points tall image for this purpose (154x44 in retina), as it is stated in the documentation. But my image does not fit to my uiswitch, it seems ugly, the default style hides my one, like on the attached image.

我应该设置什么才能让它以正确的方式工作?

What should I set to make it work in a proper way?

推荐答案

Apple没有 UISwitch 的外观API。您可以设置色调颜色属性( onTintColor )。但我猜这不是你想要的。自定义UISwitch的问题在于Apple有机会拒绝您的应用。

Apple doesn't have an Appearance API for UISwitch. You can set a tint color property (onTintColor). But that's not what you want, I guess. The problem about customizing UISwitch is that there's the opportunity that Apple will reject your app.

但是有一些自定义开关的API,例如 RCSwitch ()或 TTSwitch 。一个很好的教程和如何使用 RCSwitch 的例子可以在这里找到:。

But there are some APIs for a custom switch such as RCSwitch(https://github.com/robertchin/rcswitch) or TTSwitch. A good tutorial and example of how to use RCSwitch can be found here: http://www.raywenderlich.com/23424/photoshop-for-developers-creating-a-custom-uiswitch.

这篇关于正确定制uiswitch图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:05