为什么UISwitch onImage/offImage属性在iOS 7上不起作用? [英] Why UISwitch onImage/offImage properties are not working on iOS 7?

查看:1194
本文介绍了为什么UISwitch onImage/offImage属性在iOS 7上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有这两个选项/属性并弃用它们有什么意义?

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

来自Apple文档:

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

我现在该怎么办?是否将所有UISwitch替换为UIButtons?

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

推荐答案

使用UIButton的selected属性将其用作开关.设置UIButton的UIControlStateSelectedUIControlStateNormal的图像以对其进行自定义.

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

这篇关于为什么UISwitch onImage/offImage属性在iOS 7上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆