如何阅读UISlider拇指图像的大小 [英] How to read size of UISlider thumb image

查看:95
本文介绍了如何阅读UISlider拇指图像的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在UISlider中将拇指放在拇指上方的另一个UIView。为此,我需要拇指图像的宽度。在iOS6中,这很好用。我可以使用:

I'm trying to position an additional UIView centered above the thumb in a UISlider. To do this, I need the width of the thumb image. In iOS6, this works fine. I can use:

CGFloat thumbWidth = self.navSlider.currentThumbImage.size.width;

(如答案所示:如何获得UISlider拇指图像的中心

这在iOS7中返回0.0f。我也试过用它来阅读:

This returns 0.0f in iOS7. I've also tried reading it using:

UIImage *thumb = [self.navSlider thumbImageForState:UIControlStateNormal];

但拇指最终为零。

是否可以读取默认滑块拇指图像的大小?或者我必须找到它,设置一个常量,以及Apple如何在以后不改变它?

Is it possible to read the size of the default slider thumb image? Or will I have to find it, set a constant, and how Apple doesn't change it later?

推荐答案

关于 currentThumbImage 属性说:


如果没有设置自定义拇指图像
setThumbImage:forState:方法,此属性包含值nil。
在这种情况下,接收方使用默认的拇指图像进行
绘图。

If no custom thumb images have been set using the setThumbImage:forState: method, this property contains the value nil. In that situation, the receiver uses the default thumb image for drawing.

<$>上的文档c $ c> thumbImageForState:不太清楚:


返回值与指定状态关联的拇指图像,如果无法检索到合适的图片,则
nil。

我想你可能是运气不佳试图找出默认的拇指大小。如何安装看起来与系统映像完全相同的自定义拇指图像?这样就可以解决苹果公司从你身下改掉它的问题。

I think you might be out of luck trying to figure out the default thumb size. How about installing a "custom" thumb image that looks exactly like the system image? That would solve the problem of Apple changing it out from under you.

这篇关于如何阅读UISlider拇指图像的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆