我可以将进度添加到 UISlider 中吗?

发布于 2024-09-09 08:36:54 字数 679 浏览 2 评论 0原文

这张图片显示了我想要的,我只是制作一个自定义电影播放控制器。

替代文本 http://www.imagechicken.com/uploads/1279252703012036800.png

我知道如何制作自定义 uislider,如下代码所示,

    playSlider.backgroundColor=[UIColor clearColor];
    [playSlider setThumbImage:[UIImage imageNamed:@"sliderButton.png"] forState:UIControlStateNormal];
    [playSlider setMaximumTrackImage:[UIImage imageNamed:@"sliderGray.png"] forState:UIControlStateNormal];
    [playSlider setMinimumTrackImage:[UIImage imageNamed:@"sliderBlue.png"] forState:UIControlStateNormal];

但这对我没有帮助。有什么想法吗?感谢您的任何建议!

This picture shows what i want , i just making a custom movieplay controller.

alt text http://www.imagechicken.com/uploads/1279252703012036800.png

I know how to make a custom uislider as code below

    playSlider.backgroundColor=[UIColor clearColor];
    [playSlider setThumbImage:[UIImage imageNamed:@"sliderButton.png"] forState:UIControlStateNormal];
    [playSlider setMaximumTrackImage:[UIImage imageNamed:@"sliderGray.png"] forState:UIControlStateNormal];
    [playSlider setMinimumTrackImage:[UIImage imageNamed:@"sliderBlue.png"] forState:UIControlStateNormal];

but that can not help me .Is there any ideas? Thank you for any advices!

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

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

发布评论

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

评论(3

薯片软お妹 2024-09-16 08:36:54

我认为只有当拇指不允许离开蓝色(已加载)区域时,您才能摆脱 UISlider 的束缚。然后,您可以将非活动(已卸载)轨道绘制到实际滑块边界的右侧,并在视频加载时更新滑块的边界,这会增加蓝色区域。但您仍然需要对滑块拇指的相对进度进行正确的数学计算。

如果您需要拇指滑入卸载区域,或者您想避免重新计算带来的麻烦,您应该构建自己的控件。不幸的是,UISlider 本身并不是一个高度可定制的控件。

I think you could get away with a UISlider only if the thumb was never allowed to leave the blue (loaded) area. Then you could draw the inactive (unloaded) track to the right of the actual slider bounds, and just update the bounds for the slider as the video loads, which would increase the blue area. But you'd still have to do the right math for the slider thumb's relative progress.

If you need the thumb to swipe into the unloaded area, or you want to avoid a headache with the recalculation, you should just build your own control. Unfortunately, the UISlider is not a highly customizable control by itself.

童话 2024-09-16 08:36:54

您应该能够在 UISlider 上子类化 drawRect 来自定义它,但我可能是错的。

You should be able to subclass drawRect on the UISlider to customize that, but I may be wrong.

束缚m 2024-09-16 08:36:54

重写drawRect:不是一个好主意。
您必须创建一个包含以下内容的自定义对象:
一个用于播放/暂停的 UIButton,一个用于滑块的 UISlider,一个用于静音开/关的 UIButtons,
和一个卷的UIView(你必须自己实现)

其实并不难,只是一个容器对象。

overriding drawRect: is not a good idea.
You will have to make a custom object containing something like:
an UIButton for the play/pause, an UISlider for the slider, an UIButtons for the mute on/off,
and a UIView for the volume (you will have to implement by your self)

Actually is not difficult, is just an container object.

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