Firemonkey的多重效果

时间:2017-02-24 13:40:06

标签: delphi firemonkey effect

使用Firemonkey(柏林更新2)是否可以在TButton上使用一起工作的TShadowEffect和TGlowEffect?

要获得暗影效果,我需要禁用发光效果。

1 个答案:

答案 0 :(得分:6)

制作复合组件:将TButton置于TRectangle(形状)内;将TShadowEffect附加到TButton,将TGlowEffect附加到外部TRectangle容器。

unit FMX_TwoEffects;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Effects,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Rectangle1: TRectangle;
    ShadowEffect1: TShadowEffect;
    GlowEffect1: TGlowEffect;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.fmx}

end.

(FMX文件)

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 146
  ClientWidth = 243
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object Rectangle1: TRectangle
    Fill.Kind = None
    Position.X = 20.000000000000000000
    Position.Y = 20.000000000000000000
    Size.Width = 113.000000000000000000
    Size.Height = 37.000000000000000000
    Size.PlatformDefault = False
    Stroke.Kind = None
    object Button1: TButton
      Align = Client
      Size.Width = 113.000000000000000000
      Size.Height = 37.000000000000000000
      Size.PlatformDefault = False
      TabOrder = 0
      Text = 'Button1'
      object ShadowEffect1: TShadowEffect
        Distance = 5.000000000000000000
        Direction = 45.000000000000000000
        Softness = 0.300000011920929000
        Opacity = 0.600000023841857900
        ShadowColor = claBlack
      end
    end
    object GlowEffect1: TGlowEffect
      Softness = 0.400000005960464400
      GlowColor = claGold
      Opacity = 0.899999976158142100
    end
  end
end