iOS Tutorial Animations

It is very simple to add nice animation effects to your layout. Animations are important. It makes it easier for the user to track the layout changes.

By default, when a layout is loaded (or resized) the layout is animated. You can control the dumping ratio and duration in the main page settings:

SS-2014-10-27_17.44.37.png


It also simple to add animations when you change the layout programmatically.
View.SetLayoutAnimated - Changes the view position and size and allows you to animate the change.
View.SetAlphaAnimated - Smoothly changes the alpha level (transparency level).
View.SetColorAnimated - Smoothly changes the background color.

The attached example demonstrates the three animations.
You can see it in this video (it looks better on a real device):
Make sure to switch to HD by clicking on the small gear button.

 

Attachments

  • Animations.zip
    3 KB · Views: 952

GiulioVale

Active Member
Licensed User
Longtime User
Really strange but is like 100%y assume a different value in release mode. A first execution show an height, the second another one
 

Fusseldieb

Active Member
Licensed User
Longtime User
Oh, "SetLayoutAnimated" is supported by B4i too?!
I'm seriously thinking of buying B4i :)
It seems that I can port my Android App without bigger troubles to iOS.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can rotate a view with this code:
B4X:
Sub RotateView(View As View, DurationMs As Int, Angle As Double)
   Dim no As NativeObject = Me
   no.RunMethod("rotateView:::", Array(View, DurationMs, Angle * cPI / 180))
End Sub

#If OBJC
- (void) rotateView:(UIView*)view :(int)DurationMs :(double)angle {
   [UIView animateWithDuration:DurationMs / 1000.0 delay:0.0f
     options:UIViewAnimationOptionCurveEaseOut animations:^{
  view.transform = CGAffineTransformMakeRotation(angle);
  } completion:^(BOOL finished) {

  }];
}
#End If

'Example:
RotateView(Button1, 1000, 180)

You will need a timer if you want to rotate it multiple times.
 

MotoMusher

Active Member
Licensed User
Longtime User
I receive the following error when attempting to run

B4X:
Sub RotateView(View As View, DurationMs As Int, Angle As Double)
   Dim no As NativeObject = Me
   no.RunMethod("rotateView:::", Array(View, DurationMs, Angle * cPI / 180))
End Sub


Method not found: rotateView::, target: <b4i_cdetail: (null)>

If instead of "Me" I use the page variable, I get
Method not found: rotateView:::, target: Page (vc): Claim
 

MotoMusher

Active Member
Licensed User
Longtime User
I am passing an imagevew to the Sub RotateView. It's almost as if "rotateView:::" doesn't exist?

"pointer" is defined in process_globals as an imageview, and initialized in another sub, and already displayed on screen.

Calling it like this:
B4X:
Sub loctimer_Tick
   RotateView(pointer, 1000, g.TrueHead)
End Sub

Sub RotateView(View As View, DurationMs As Int, Angle As Double)
   Dim no As NativeObject = Me
   no.RunMethod("rotateView:::", Array(View, DurationMs, Angle * cPI / 180))
End Sub


Other methods I have tried which generate same error are:
Dim no As NativeObject = pgCdetail

and
Dim no As NativeObject = pgCdetail.RootPanel


Error occurred on line: 147 (CDetail)
Method not found: rotateView:::, target: <b4i_cdetail: (null)>
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
Centers +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 426
Centers -[B4INativeObject RunMethod::] + 164
Centers -[b4i_cdetail _rotateview:::] + 1734
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
Centers +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
Centers -[B4IShell runMethod:] + 574
Centers -[B4IShell raiseEventImpl:method:args::] + 1998
Centers -[B4IShellBI raiseEvent:event:params:] + 1340
Centers __24-[B4ITimer startTicking]_block_invoke + 290
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 66
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 2030
libdispatch.dylib <redacted> + 712
libdispatch.dylib <redacted> + 394
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1574
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Excepting you don't have forgotten to copy paste the Objc code, you have done everything right, click on Tools->Clean Project and compile your app again
 
Last edited:
Top