UISlider alpha 问题

发布于 2024-08-01 16:28:19 字数 478 浏览 3 评论 0原文

我想弄清楚这样一个问题:

我有一个 UIView 派生类,其中有多个控件。 其中一些必须根据所选模式出现和消失。 这是通过将 aplha 值设置为相关组件来实现的。

所有控件都以正常方式通过 initWithFrame 中的代码按程序添加。 所有控件均按预期工作,但 UISlider 除外! 在 initWithFrame 中将其初始 alpha 设置为 0.0f 没有任何效果。 这特别奇怪,因为在代码中进一步设置其 alpha 工作正常。 该组件已经存在,并且 NSLog 显示它的地址并正确设置了 alpha。 但真正的 alpha 是 1.0f!

如果我将 UISlider 替换为任意其他视图,它可以正常工作。 为什么?

我的猜测 - 这是因为内部动画过程会干扰创建时的 alpha 值。

我使用的唯一解决方法 - 将滑块放置在虚拟视图上并设置其透明度。

有人知道另一种解决方案吗?

I'm want to figure out such an issue:

I have a UIView dervied class in which there are several controls. Some of them must appear and disappear depending on selected mode. This is made by means of setting aplha value to respected component.

All controls adds procedurally through code in initWithFrame in normal way. All controls works as expected but UISlider! Setting its initial alpha to 0.0f in initWithFrame have no effect. This is especially strange because futher setting of its alpha in code works OK. This component already exists and NSLog displays it's address and setted alpha correctly. But real alpha is 1.0f!

If I replace UISlider to arbitrary other view its works properly. Why?

My guess - this is because of internal animation processes which is interfere alpha value upon creation.

The only workaround I use - to place slider on dummy view and set it's transparency.

Does anybody knows another solution?

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

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

发布评论

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

评论(1

拔了角的鹿 2024-08-08 16:28:19
uislider.hidden = YES;
uislider.hidden = YES;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文