我希望能够在Delphi with firemonkey中复制https://github.com/jdg/MBProgressHUD的HUD功能。
这是iPhone上的样子:
这是iPhone上的样子:
Fill.Kind
设置为bkNone
,将其Fill.Color
设置为Null
。此外,将其Transparency
属性设置为True,并将其BorderStyle
设置为bsNone
。Stroke.Kind
属性设置为bkNone
。将其Fill.Color
设置为Gray
,将其Opacity
设置为0.5。TAniIndicator
和TLabel
,它们的父项都是该表单。它们的Opacity
保持在1.0。如果需要,还可以创建一个TImage
,并将其大小和位置与TAniIndicator
完全相同。TFloatAnimation
来处理TAniIndicator,并将标签文本简单地更改为您想要显示的任何消息。理想情况下,您只需创建一个过程,接受字符串或整数作为变量,然后修改文本和指示器/图像以匹配该变量。例如;Procedure TForm1.Process(Mode : Integer);
Begin
if Mode = 1 then
begin
AniIndicator1.Enabled := True;
AniIndicator1.Visible := True;
Image1.Visible := False;
Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
Label1.Text := 'Loading';
End
else if Mode = 2 then
Begin
AniIndicator1.Enabled := False;
AniIndicator1.Visible := False;
Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
Image1.Bitmap.LoadFromFile('Tick.png');
Image1.Visible := True;
Label1.Text := 'Complete!';
end;
end;
您可以在主窗体中创建一个tpanel,然后将上述包含的窗体添加为子组件。然后使用有效的模式变量调用您创建的过程,它将按照代码中指定的方式运行。很容易添加更多模式,我已经在自己的应用程序中执行了类似的操作(尽管与创建指示器不同,而是与相关)。