Offset UISlider Min/Max value images
I'm trying to offset the x/y position of a UISlider's min and max value images. Currently, I'm sublcassing UISlider and am setting the maximum value image like this:
[self setMaximumValueImage:[UIImage imageNamed:@"circle_with_plus"]];
However, I need this image to be closer to the actual UISlider 开发者_JS百科and have little control over visual assets on this project. I've tried using
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds
However, I'm my min/max value images may change size dynamically so I'm not sure how to properly implement it in this case. Is there a different way to move the asset? Thanks
No, there is no other way to reposition the minimum or maximum value images. maximumValueImageRectForBounds:
gets invoked every time the slider lays out its subviews, and laying out the subviews happens whenever you change the maximumValueImage
, so it is sufficient to do:
@implementation MyCustomSlider
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds {
CGRect r = [super maximumValueImageRectForBounds:bounds];
r.origin.x -= 3;
return r;
}
@end
精彩评论