进度视图 xcode 的高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11302325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
height of progress view xcode
提问by Amelia777
Is there a way to change the height of a progress view bar in Xcode?
有没有办法在 Xcode 中更改进度视图栏的高度?
I am using Xcode 4.3 and need a vertical progress bar. I rotated the bar but now cannot change the height and is displays as a circle.
我正在使用 Xcode 4.3 并且需要一个垂直进度条。我旋转了栏,但现在无法更改高度并显示为一个圆圈。
Also a more effective way to rotate the progress bar would be helpful.
旋转进度条的更有效方法也会有所帮助。
Thanks!
谢谢!
回答by CodaFi
Some have reported that changing it's frame manually will work:
有人报告说,手动更改框架会起作用:
[self.progressView setFrame:CGRectMake(0, 0, 300, 25)];
Whereas others have reported that a CGAffineTransform() works as well:
而其他人报告说 CGAffineTransform() 也可以工作:
[self.progressView setTransform:CGAffineTransformMakeScale(1.0, 3.0)];
As for rotation, use:
至于旋转,请使用:
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
[self.progressView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(angle))];
回答by Shoaib
This question is already answered here How to increase height of UIProgressView
这个问题已经在这里回答了如何增加 UIProgressView 的高度
@implementation UIProgressView (customView)
-(CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(self.frame.size.width,9);
return newSize;
}
@end
回答by Hardik Patel
Here code is help for you. you want to set uislider height change CGAffineTransformMakeScale height.
这里的代码对你有帮助。您想设置 uislider 高度更改 CGAffineTransformMakeScale 高度。
UISlider *slider_progres = [[UIProgressView alloc]initWithFrame:CGRectMake(0, 56, 320, 15)];
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
slider_progres.transform = transform;
回答by Atanu Mondal
I think it will help you.
我想它会帮助你。
[self.progressView setTransform:CGAffineTransformMakeScale(1.0, 3.0)];
回答by Tzegenos
For me that works onlyif you inherit from UIProgressView class.
对我来说,只有从 UIProgressView 类继承才有效。
[self.progressView setTransform:CGAffineTransformMakeScale(1.0, 3.0)];
Example:
例子:
@implementation CustomProgressView
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self setTransform:CGAffineTransformMakeScale(1.0, 3.0)];
}
return self;
}
@end
Other class:
其他类:
@property (weak, nonatomic) IBOutlet CustomProgressView *cProgressView;
回答by Brad Robinson
I've just had a similar problem to this in iOS 7.
我刚刚在 iOS 7 中遇到了类似的问题。
If you use [UIProgressView appearance]
to set the progress and track images, the progress view will appear correctly for progress bars loaded from a Xib file.
如果您使用[UIProgressView appearance]
设置进度和跟踪图像,进度视图将正确显示从 Xib 文件加载的进度条。
If however you programatically create a UIProgressView (after setting images through appearance
), the appearance images will be used however it's height will be stuck and "2", the progress bar will be clipped and even calling setFrame
won't fix it.
但是,如果您以编程方式创建 UIProgressView(通过 设置图像后appearance
),将使用外观图像,但是它的高度将被卡住并且“2”,进度条将被剪裁,甚至调用setFrame
也无法修复它。
The fix is to programatically set the images directly on the programatically created UIProgressView - rather than relying on the appearance settings.
解决方法是直接在以编程方式创建的 UIProgressView 上以编程方式设置图像 - 而不是依赖外观设置。