gpt4 book ai didi

ios - XCode 创建一个 Button Toggle,显示一张图像用于 On 和一张用于 Off 功能

转载 作者:行者123 更新时间:2023-11-29 10:59:26 27 4
gpt4 key购买 nike

我正在尝试在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com