我只是想在我的 iPhone 应用程序中添加一个vertical slider
和progressBar
,但每次我尝试将它们转换为将它们旋转 90 度时,它们要么消失要么伸展。有没有办法防止这种情况?我想要发生的只是让滑块和进度条显示为垂直但保持相同的大小并具有相同的外观。
添加:
我在这里找到了如何旋转的代码:
define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
[self.progressView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(angle))];
我在 中创建slider
and progress view
,stoyboard
将其链接到我在 中声明的变量ViewController.m
。随着“角度”的增加,progress ba
r 和slider
越来越伸展。最后,当我旋转 90 时,它progress bar
消失了,slider
看起来只是一个拇指图像,但没有slider bar
。
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Create a transformation with just the rotation
CGAffineTransform transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));
//Now apply our scale
transform = CGAffineTransformScale(transform, 2, 2);
//Now set the transform on the object to the combined rotation/scale transform.
[self.shield2 setTransform: transform];
CGAffineTransform sliderRotation = CGAffineTransformIdentity;
sliderRotation = CGAffineTransformRotate(sliderRotation, -DEGREES_TO_RADIANS(89));
self.shield.transform = sliderRotation;
}