How to read size of UISlider thumb image

前端 未结 5 1271
一生所求
一生所求 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条回答
  •  猫巷女王i
    2021-01-18 07:53

    I believe this will sometimes return 0, if the layout flow hasn't completed. I had some trouble with it.

    CGRect thumbRect = [self thumbRectForBounds:self.bounds
                                      trackRect:[self trackRectForBounds:self.bounds]
                                          value:self.value];
    CGFloat thumbDiameter = CGRectGetHeight(thumbRect);
    

提交回复
热议问题