如何制作 firemonkey HUD 窗口
我想在 Delphi 中复制 https://github.com/jdg/MBProgressHUD 的 HUD 功能火猴。
这是 iPhone 中的样子:
主要问题是如何使表单半透明和半透明。完全去除边框。
I wanna to replicate the HUD functionality of https://github.com/jdg/MBProgressHUD in Delphi with firemonkey.
This is what look like in iPhone:
The main issue is how make the form semi-transparent & completely remove the borders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建 Firemonkey HD 表单,将其
Fill.Kind
设置为bkNone
,将Fill.Color
设置为Null
。此外,将其Transparency
属性设置为 True,将BorderStyle
设置为bsNone
。创建一个 TRectangle(或任何形状),并将
Stroke.Kind
属性设置为bkNone
。将其Fill.Color
设置为Gray
,将Opacity
设置为0.5。创建一个
TAniIndicator
和TLabel
,并将两者的父级作为表单。它的Opacity
保持为 1.0。或者,还可以创建一个TImage
并使其大小和位置与TAniIndicator
完全相同。从那里开始,当您想要更改图像(为勾号等)和标签文本以更改为您想要显示的任何消息时,只需在 TAniIndicator 上使用
TFloatAnimation
即可。理想情况下,您只需创建一个接受字符串或整数作为变量的过程,然后修改文本和指示器/图像以匹配它。例如;然后,您可以在主窗体中创建一个 tpanel,然后添加上述窗体(包含 TAniIndicator、标签和矩形)作为子组件。然后,您使用有效的模式变量调用您创建的过程,它将按照您在代码中指示的方式运行。添加更多模式非常容易,我已经对自己的一个应用程序做了类似的操作(尽管它与
TRectangle
相关,而不是创建指标)。Create your Firemonkey HD form, set it's
Fill.Kind
tobkNone
, and it'sFill.Color
toNull
. Additionally, set it'sTransparency
property to True, and it'sBorderStyle
tobsNone
.Create a TRectangle (or any shape), and set the
Stroke.Kind
property tobkNone
. Set it'sFill.Color
toGray
, it'sOpacity
to 0.5.Create a
TAniIndicator
andTLabel
with parent of both as the form. It'sOpacity
remains at 1.0. Optionally, also create aTImage
and make it the exact same size and position as theTAniIndicator
.From there, it's simply a case of working with
TFloatAnimation
on the TAniIndicator when you want to change the image (to a tick or such) and the label text to simply change to whatever message you want to display. Ideally, you simply create a procedure that accepts either a string or integer as a variable, and then modify the text and indicator/image to match that. For example;You can then create a tpanel in your main form, and then add the above form (that contains the
TAniIndicator, label, and rectangle
) as a child component. You then call the procedure you created with a valid mode variable and it'll run as you indicated in the code. It's easy enough to add more modes and i've done something similar with one of my own applications (although it was related toTRectangle
rather than creating an indicator).