How to get the center of the thumb image of UISlider

后端 未结 12 1853
挽巷
挽巷 2020-11-29 23:18

I\'m creating a custom UISlider to test out some interface ideas. Mostly based around making the thumb image larger.

I found out how to do that, <

12条回答
  •  忘掉有多难
    2020-11-29 23:37

    I would like to know why none of you provide the simplest answer which consist in reading the manual. You can compute all these values accurately and also MAKING SURE THEY STAY THAT WAY, by simply using the methods:

    - (CGRect)trackRectForBounds:(CGRect)bounds
    - (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value
    

    which you can easily find in the developer documentation.

    If thumb image changes and you want to change how it's positioned, you subclass and override these methods. The first one gives you the rectangle in which the thumb can move the second one the position of the thumb itself.

提交回复
热议问题