自定义开/关图像 iOS 7.0 UI 开关

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19410300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:23:01  来源:igfitidea点击:

Custom On/Off Image iOS 7.0 UI Switch

iosxcodeuiswitch

提问by Wuzseen

In iOS 7 switches don't allow custom on/off images by default. While I can still set them in the Interface Builder it doesn't show up.

在 iOS 7 中,默认情况下开关不允许自定义开/关图像。虽然我仍然可以在 Interface Builder 中设置它们,但它没有显示出来。

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/TransitionGuide.pdf

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/TransitionGuide.pdf

The transition guide merely notes that it isn't on by default anymore. Presumably there is a way to change that so I do use the images I have.

转换指南只是指出它不再默认开启。大概有一种方法可以改变它,所以我确实使用了我拥有的图像。

采纳答案by Kristopher Johnson

Can you use a UIButton instead, using the "selected" state to mean "on"?

您可以使用 UIButton 代替,使用“已选择”状态表示“打开”吗?

回答by liamnichols

Apple never let this feature go live... I believe you can file a bug report about it if you want to see it in the future...

苹果从来没有让这个功能上线......我相信如果你想在未来看到它,你可以提交一个关于它的错误报告......

I've got around this issue by using a drop in replacement called SevenSwitch.

我通过使用名为SevenSwitch 的替代品解决了这个问题。

回答by landonandrey

Download thesetwo files:

下载两个文件:

SevenSwitch.h 
SevenSwitch.m

Include them to your project, it is very easy for customizing.

将它们包含到您的项目中,很容易定制。