Blog

All Blog Posts  |  Next Post  |  Previous Post

Block Animations with TMS iCL

Wednesday, July 3, 2013

This week, we had a support question on Block Animations with TMS iCL, or in other words, how to animate for example a TTMSFMXNativeUIView?

To be honest, after all the hard work around the TMS iCL components, demos and documentation there wasn't room left for some more diving inside the iOS frameworks and features, so we couldn't really answer YES to the question until it was sorted out if it was even possible. When we got the question about Block Animations we were really curious if it would actually do anything since we are not working directly in XCode with the native language. So we dropped everything and started testing.

It was clear that even this feature of the iOS core animation framework would work as expected without any issues. We dropped a TTMSFMXNativeUIView instance on the form, dropped a button with the following code:

TUIView.OCClass.beginAnimations(nil, nil);  
TUIView.OCClass.setAnimationDuration(0.4);  
TMSFMXNativeUIView1.SetBounds(0, 0, 320, 480);  
TUIView.OCClass.commitAnimations;  
and some initialization to position the view out of sight:
TMSFMXNativeUIView1.SetBounds(0, 480, 320, 480); 
Starting the application and clicking the button slides the view in from the bottom.

This is only a basic animation and in the documentation of Block Animations there were some more complex samples such as animating the alpha of a component and the animation curve. The next sample animates a flip on the view and shows a second view:
var
  vwRemove, vwAdd: TTMSFMXNativeUIView;
begin
  vwRemove := nil;
  vwAdd := nil;
  if Assigned(TMSFMXNativeUIView1.Parent) then
  begin
    vwRemove := TMSFMXNativeUIView1;
    vwAdd := TMSFMXNativeUIView2;
  end
  else if Assigned(TMSFMXNativeUIView2.Parent) then
  begin
    vwRemove := TMSFMXNativeUIView2;
    vwAdd := TMSFMXNativeUIView1;
  end;

  if Assigned(vwRemove) and Assigned(vwAdd) then
  begin
    TUIView.OCClass.beginAnimations(nil, nil);
    TUIView.OCClass.setAnimationTransition(UIViewAnimationTransitionFlipFromLeft, TMSFMXNativeUIView3.View, False);
    TUIView.OCClass.setAnimationCurve(UIViewAnimationCurveEaseIn);
    TUIView.OCClass.setAnimationDuration(0.8);
    vwRemove.Parent := nil;
    vwAdd.Parent := TMSFMXNativeUIView3;
    TUIView.OCClass.commitAnimations
  end;
end;
The demo for this code can be found at the following link:
https://download.tmssoftware.com/download/FlipDemo.zip



Pieter Scheldeman




This blog post has not received any comments yet.



Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post