我如何将 UILabel 放在 UISlider 的拇指上...这样当我移动拇指时...UILabel 也会移动...就像在拇指上一样...
有什么想法吗??
最佳答案
试试这个
yourLabel = [[UILabel alloc]initWithFrame:....];
//Call this method on Slider value change event
-(void)sliderValueChanged{
CGRect trackRect = [self.slider trackRectForBounds:self.slider.bounds];
CGRect thumbRect = [self.slider thumbRectForBounds:self.slider.bounds
trackRect:trackRect
value:self.slider.value];
yourLabel.center = CGPointMake(thumbRect.origin.x + self.slider.frame.origin.x, self.slider.frame.origin.y - 20);
}
通过使用此代码段,我可以获得最准确的值。
关于objective-c - UILabel 在 UISlider 拇指上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3510961/