我想将我的滑块和我的拇指图像一起垂直移动。然而,搬家是错误的。
在水平它完美地工作但不是垂直
- (void)viewDidLoad
{
CGAffineTransform trans = CGAffineTransformMakeRotation(-M_PI * 0.5);
self.SDSlider.transform = trans;
}
- (IBAction)sliderValueChanged:(UISlider *)sender
{
self.SDlabel.text = [NSString stringWithFormat:@"%d", (int)sender.value];
CGRect trackRect = [self.SDSlider trackRectForBounds:self.SDSlider.bounds];
CGRect thumbRect = [self.SDSlider thumbRectForBounds:self.SDSlider.bounds
trackRect:trackRect
value:self.SDSlider.value];
self.testSDlabel.center = CGPointMake(thumbRect.origin.x + self.SDSlider.frame.origin.x, self.SDSlider.frame.origin.y - 20);
self.testSDlabel.text = [NSString stringWithFormat:@"%.0f", self.SDSlider.value];
}
标签从左向右移动,而不是从底部向上移动