xcode 如何改变灰色的hud地方的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8132204/
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
How to change the color of hud place of gray color
提问by Nimit Parekh
My question is the "How to change the color of the HUD in place of gray color"
我的问题是“如何更改 HUD 的颜色而不是灰色”
- In hud their is a gray color for the hud.
- How to change the color of that color replace with off green color
- 在 hud 中,他们的 hud 是灰色的。
- 如何更改该颜色的颜色替换为绿色
in below image their is hud and how to change the gray color replace with another off green color
在下图中,它们是 hud 以及如何将灰色替换为另一种绿色
Thanks in advance. Nimit Parekh.
提前致谢。尼米特·帕雷克。
采纳答案by Nimit Parekh
I founding out the solution of this problem and implemented into my project.
我找到了这个问题的解决方案并实施到我的项目中。
In Following method is use into the MBProgressHud.m their is a manage the color of the Hud background color so the change color for that we change the value of the CGContextSetRGBFillColor argument change.
在以下方法中使用 MBProgressHud.m,它们是管理 Hud 背景颜色的颜色,因此我们更改 CGContextSetRGBFillColor 参数的值更改颜色。
If apply this value then we gets the green color of the hud.
如果应用此值,则我们将获得 hud 的绿色。
- (void)fillRoundedRect:(CGRect)rect inContext:(CGContextRef)context {
float radius = 10.0f;
CGContextBeginPath(context);
CGContextSetRGBFillColor(context, 17.0/255, 64.0/255, 42.0/255, 0.8);
CGContextMoveToPoint(context, CGRectGetMinX(rect) + radius, CGRectGetMinY(rect));
CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMinY(rect) + radius, radius, 3 * M_PI / 2, 0, 0);
CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMaxY(rect) - radius, radius, 0, M_PI / 2, 0);
CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMaxY(rect) - radius, radius, M_PI / 2, M_PI, 0);
CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMinY(rect) + radius, radius, M_PI, 3 * M_PI / 2, 0);
CGContextClosePath(context);
CGContextFillPath(context);
}
回答by mishimay
MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
HUD.color = [UIColor purpleColor];
...
回答by venkatrao ramakurti
Swift 3:
斯威夫特 3:
let hud:MBProgressHUD = MBProgressHUD.showAdded(to: self.view, animated: true)
hud.bezelView.color = UIColor.green // Your backgroundcolor
hud.bezelView.style = .solidColor // you should change the bezelview style to solid color.
回答by Marcos Reboucas
MBProgressHUD.m has a "drawRect:(CGRect)rect" method where you will find the gray color set in CGContext function:
MBProgressHUD.m 有一个“drawRect:(CGRect)rect”方法,您可以在其中找到在 CGContext 函数中设置的灰色:
CGContextSetGrayFillColor (context, 0.0f, self.opacity);
You can just substitute CGContextSetGrayFillColor by another function that uses RGB (or other) color type:
您可以用另一个使用 RGB(或其他)颜色类型的函数替换 CGContextSetGrayFillColor:
CGContextSetRGBFillColor (context, 0/255.0f, 132/255.0f, 200/255.0f, 0.9f);
回答by user1760527
_mHud.bezelView.color = [UIColor blackColor];
_mHud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
_mHud.contentColor = [UIColor whiteColor];
回答by alpere
Version 0.8 of MBProgressHud let's you set the color in its init method: It is set to nil by default.
MBProgressHud 0.8 版让您可以在其 init 方法中设置颜色:默认设置为 nil。
in MBProgressHUD.m:
在 MBProgressHUD.m 中:
- (id)initWithFrame:(CGRect)frame {
.
.
.
self.color = [UIColor greenColor];