Size of default thumb image for iOS slider?

JohnK picture JohnK · May 4, 2013 · Viewed 18.3k times · Source

What is the exact size (width, height) of the (default) thumb image for the iOS slider? Is there perhaps some clever way to coax this out of the system (XCode, iOS)?

I tried

int thumbWidth = slider.currentThumbImage.size.width;

which I found here on this site, but it comes back with 0.

Additional question: The Xcode debugger shows this undocumented variable in the UISlider: CGFloat _hitOffset. Does anyone by chance know what it is and what it's for?

Answer

Rudolf Adamkovič picture Rudolf Adamkovič · May 19, 2014

What about this? Works for me:

CGRect trackRect = [self trackRectForBounds:self.bounds];
CGRect thumbRect = [self thumbRectForBounds:self.bounds trackRect:trackRect value:0];
CGSize thumbSize = thumbRect.size;