偏移UISlider最小值/最大值图像 [英] Offset UISlider Min/Max value images

查看:136
本文介绍了偏移UISlider最小值/最大值图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试补偿UISlider的最小和最大值图像的x / y位置。
当前,我正在订阅UISlider,并设置最大值图像,如下所示:

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"]];

但是,我需要此图像更接近实际的UISlider,并且对视觉资产的控制很少这个项目。我试过使用

However, I need this image to be closer to the actual UISlider 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

推荐答案

否,没有其他方法可以重新定位最小值或最大值的图像。 maximumValueImageRectForBounds:每次滑块布置其子视图时都会被调用,并且每次更改 maximumValueImage 时,都会布置子视图。 ,这样就足够了:

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

这篇关于偏移UISlider最小值/最大值图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆