Why UISwitch onImage/offImage properties are not working on iOS 7?

陌路散爱 提交于 2019-12-02 06:55:52

问题


Whats the point of having these two options/properties and deprecate them?

From Apple docs:

offImage
The image displayed while the switch is in the off position.

@property(nonatomic, retain) UIImage *offImage
Discussion
In iOS 7, this property has no effect.

In iOS 6, this image represents the interior contents of the switch. The image you specify is composited with the switch’s rounded bezel and thumb to create the final appearance.

Availability
Available in iOS 6.0 and later.
Declared In
UISwitch.h

What should I do now? Replace all UISwitches with UIButtons?


回答1:


Use UIButton's selected property to use it as a switch. Set images for UIButton's UIControlStateSelected and UIControlStateNormal to customise it.



来源:https://stackoverflow.com/questions/22843747/why-uiswitch-onimage-offimage-properties-are-not-working-on-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!