How to read size of UISlider thumb image

前端 未结 5 1259
一生所求
一生所求 2021-01-18 07:02

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:

5条回答
  •  长发绾君心
    2021-01-18 07:54

    The docs on the currentThumbImage property say:

    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.

    The docs on thumbImageForState: are less clear:

    Return Value The thumb image associated with the specified state, or nil if an appropriate image could not be retrieved.

    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.

提交回复
热议问题