【Delphi】 Android&IOS 实现frame滑动页面。

【Delphi】 Android&IOS 实现frame滑动页面。

先看效果图。

思路比较简单,利用TFloatAnimation实现frame动画。
即将进入的界面移入的同时,当前界面向左滑动。

procedure TAniFrameBase.showPage(obj: TAniFrameBase = nil;Inverse: Boolean = False);
begin
  if aniTag then Exit;            //正在显示动画则退出
  aniTag := True;
  if Inverse then               //这个是当前frame向左滑出
  begin
    fltnmtn_scroll.StartValue := 0;
    fltnmtn_scroll.StopValue :=  -Width / 2;
  end
  else begin
    Visible := True;
    BringToFront;
    fltnmtn_scroll.StartValue := Width;
    fltnmtn_scroll.StopValue := 0;
    prePage := obj;
    if obj <> nil then       //当前界面向左滑出
    begin
      prePage.Visible := True;
      prePage.showPage(nil,True);
    end;
  end;
  fltnmtn_scroll.Start;      //显示界面进入
end;

回退时,当前界面向右滑出,展示界面从左滑入。

procedure TAniFrameBase.closePage(Inverse: Boolean= False);
begin
  if aniTag then Exit;
  aniTag := True;
  if Inverse then    //关闭时
  begin
    fltnmtn_scroll.StartValue := -Width / 2;
    fltnmtn_scroll.StopValue := 0;
  end
  else begin
    Visible := True;
    fltnmtn_scroll.StartValue := 0;
    fltnmtn_scroll.StopValue := Width;
    if prePage <> nil then
    begin
      prePage.Visible := True;
      prePage.closepage(True);
    end;
  end;
  fltnmtn_scroll.Start;
end;

完整代码例子:
https://download.csdn.net/download/liverry/12698805

注意:新建的TFrame,选择继承自TAniFrameBase就行了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DELPHI动态创建删除FRAME unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,FM; type TForm2 = class(TForm) Panel1: TPanel; Button2: TButton; ScrollBox1: TScrollBox; procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type TFM = Array Of TFrame1; var Form2: TForm2; aFM: TFM; procedure DeleteArrItem(var arr: TFM ; Index: Integer);stdcall; implementation {$R *.dfm} procedure DeleteArrItem(var arr: TFM ; Index: Integer); var Count: Cardinal; i:integer; begin Count := Length(arr); if (Count = 0) or (Index = Count) then Exit; Move(arr[Index+1], arr[Index], (Count-Index)* SizeOf(arr[0])); SetLength(arr, Count - 1); for I := 0 to Length(arr) - 1 do begin arr[i].Label1.Caption:=inttostr(i); end; end; procedure TForm2.Button2Click(Sender: TObject); var fram:TFrame1; begin SetLength(aFM,length(aFM)+1); aFM[length(aFM)-1] :=TFrame1.Create(nil) ; fram:=aFM[length(aFM)-1]; fram.Label1.Caption:=inttostr(length(aFM)-1); fram.Parent:=ScrollBox1; end; end. unit fm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFrame1 = class(TFrame) GroupBox1: TGroupBox; Label1: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; implementation uses unit2; {$R *.dfm} procedure TFrame1.Button1Click(Sender: TObject); begin DeleteArrItem(aFM,strtoint(label1.Caption)); ( Sender as Tbutton ).Parent.Parent.Destroy; end; end.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值