作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 XCode 中创建一个切换按钮,它是用于切换传入文本消息的打开和关闭开关。当该功能在图像上时,设计为打开。我需要为按钮打开的状态设置此图像属性。当图像关闭时。该按钮有一个显示关闭的图像。
完成此代码的最佳途径是什么。
瑞安
最佳答案
我使用:
//Create a Switch
UISwitch *myswitchbutton;
myswitchbutton.frame=CGRectMake(10, 10, 40, 50);
[self addsubview:myswitchbutton];
然后,添加图片
myswitchbutton.offImage=[UIImage imageNamed:@"off.png"];
myswitchbutton.onImage=[UIImage imageNamed:@"on.png"];
off.png 和 on.png 是自定义设计的图片
关于ios - XCode 创建一个 Button Toggle,显示一张图像用于 On 和一张用于 Off 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16676951/
我是一名优秀的程序员,十分优秀!