Iphone 如何改变hud的颜色的地方灰色的颜色

Iphone 如何改变hud的颜色的地方灰色的颜色,iphone,xcode,cocoa-touch,Iphone,Xcode,Cocoa Touch,我的问题是“如何改变HUD的颜色来代替灰色” 在hud中,它们是hud的灰色 如何更改该颜色的颜色替换为淡绿色 在下图中,他们是hud,如何改变灰色,用另一种淡绿色替换 提前谢谢。 Nimit Parekh.我找到了这个问题的解决方案,并将其应用到我的项目中 在下面的方法中,是使用到MBProgressHud.m中的,它们是一个管理Hud背景颜色的颜色的方法,因此我们更改了CGContextSetRGBFillColor参数的值change 如果应用此值,则得到hud的绿色 - (void

我的问题是“如何改变HUD的颜色来代替灰色”

  • 在hud中,它们是hud的灰色
  • 如何更改该颜色的颜色替换为淡绿色

在下图中,他们是hud,如何改变灰色,用另一种淡绿色替换

提前谢谢。
Nimit Parekh.

我找到了这个问题的解决方案,并将其应用到我的项目中

在下面的方法中,是使用到MBProgressHud.m中的,它们是一个管理Hud背景颜色的颜色的方法,因此我们更改了CGContextSetRGBFillColor参数的值change

如果应用此值,则得到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);
}
MBProgressHUD.m有一个“drawRect:(CGRect)rect”方法,您可以在CGContext函数中找到灰色集:

CGContextSetGrayFillColor (context, 0.0f, self.opacity);
您可以用另一个使用RGB(或其他)颜色类型的函数替换CGContextSetGrayFillColor:

CGContextSetRGBFillColor (context, 0/255.0f, 132/255.0f, 200/255.0f, 0.9f);

MBProgressHud的0.8版让我们在其初始方法中设置颜色: 默认情况下,它设置为零

在MBProgressHUD.m中:

- (id)initWithFrame:(CGRect)frame {
.
.
.
self.color = [UIColor greenColor];

Swift 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.

这不是一个内置的UIKit控件-您是否有机会谈论这一点?是的,我正在使用MBProgressHud,但我想将背景色更改为非黑色的图像,我插入了非绿色。只需转到实现文件并在init方法中修改颜色:)这对我来说很有效CGContextSetGrayFillColor(上下文,0.4f,self.opacity);
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.
_mHud.bezelView.color = [UIColor blackColor];
_mHud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
_mHud.contentColor = [UIColor whiteColor];