UI切换自定义

发布于 2024-10-27 23:22:26 字数 64 浏览 3 评论 0原文

我应该用 YES 和 NO 而不是 ON 和 OFF 自定义 UISwitch,我该怎么办?我不知道制作它的代码。

I should customize a UISwitch with YES and NO instead of ON and OFF, what can I do? I don't know the code for make it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是我以为 2024-11-03 23:22:26

文档没有显示用于更改 UISwitch 样式的属性,我一直实现此类功能的方式是使用 UISlider,并且您只能通过代码设置属性(至少是高级属性)。对于“是”和“否”,您可以将图像设置为滑块的左侧和右侧,对于过渡效果,您可以使用普通的动画功能,

[UIView animationWithDuration:0.1f animation^(void){
   //code here
}completion(BOOL finished){
   // set the picture here so that you don't see a squished imaged get enlarged
}];

我不知道我头顶上的属性,所以您将不得不尝试使用它,它可能是 UISlider.layer.property,因此一旦您输入第二个 .,就会出现一个列表,您可以滚动该列表以查找与您要查找的内容相匹配的内容,但不要引用我的话,我对此不太确定。

The documentation doesn't show properties for changing the style of a UISwitch, the way I've always implemented such a feature was using a UISlider, and you can set the properties only via code (the advanced properties at least). For "yes" and "no" you can make images to set to the left and right side of the slider, and for the transition effect you can use a normal animation function

[UIView animationWithDuration:0.1f animation^(void){
   //code here
}completion(BOOL finished){
   // set the picture here so that you don't see a squished imaged get enlarged
}];

I don't know the properties off the top of my head so you will have to play around with it, it's probably UISlider.layer.property so once you type the second . then a list should come up which you can scroll through to find what matches what you are looking for, but don't quote me, I'm not exactly sure on that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文