iOS Tutorial ShowPage Animated

Based on @narek adonts answer here:

this is a ShowPage animation Code Module

B4X:
'Code module
Sub Process_Globals

End Sub

'Transition: 0 = cameraIris, 1 = cameraIrisHollowOpen, 2 = cameraIrisHollowClose, 3 = cube, 4 = alignedCube, 5 = flip,
'                   6 = alignedFlip, 7 = oglFlip, 8 = rotate, 9 = pageCurl, 10 = pageUnCurl, 11 = rippleEffect, 12 = suckEffect
'Direction: 0 = FromTop, 1 = FromBottom, 2 = FromLeft, 3 = FromRight
Public Sub showPage(NavigationControl As NavigationController,PageToShow As Page,TransType As Int, Direction As Int)
    Dim TransitionType As String
    Select TransType
        Case 0
            TransitionType = "cameraIris"
        Case 1
            TransitionType = "cameraIrisHollowOpen"
        Case 2
            TransitionType = "cameraIrisHollowClose"
        Case 3
            TransitionType = "cube"
        Case 4
            TransitionType = "alignedCube"
        Case 5
            TransitionType = "flip"
        Case 6
            TransitionType = "alignedFlip"
        Case 7
            TransitionType = "oglFlip"
        Case 8
            TransitionType = "rotate"
        Case 9
            TransitionType = "pageCurl"
        Case 10
            TransitionType = "pageUnCurl"
        Case 11
            TransitionType = "rippleEffect"
        Case 12
            TransitionType = "suckEffect"
    End Select
  
    Dim FromDirection As String
    Select Direction
        Case 0
            FromDirection = "fromTop"
        Case 1
            FromDirection = "fromBottom"
        Case 2
            FromDirection = "fromLeft"
        Case 3
            FromDirection = "fromRight"             
    End Select
  
    Dim no As NativeObject=Me
    no.RunMethod("trans:::",Array(NavigationControl,TransitionType,FromDirection))
    NavigationControl.ShowPage2(PageToShow,False)
End Sub

#if OBJC

-(void) trans: (UINavigationController*)nav :(NSString*)tp :(NSString*)from
{
CATransition *transition = [CATransition animation];
transition.duration = 0.6f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = tp;
transition.subtype = from;
[nav.view.layer addAnimation:transition forKey:nil];
}

#End If

usage:

B4X:
Transition.showPage(NavControl,menuPage,6,3)

thanx a lot @narek adonts :)
 

ilan

Expert
Licensed User
Longtime User
As I know there are also other type like Pop and Push. u can add them )

there are? what i have found is this:
https://stackoverflow.com/questions...of-catransition-types-available-in-iphone-sdk


And by my opinion duration 0.6 is too much

actually, i am comparing it with Xcode and 0.6 feels the same for me..

i have started a swift 4.0 course and i am playing a little bit with animations. i find swift simpler then objc.
it is much cleaner in my opinion.

this is, for example, a SetLayoutAnimation in swift like we have in B4X


B4X:
func animateView(myView : UIView, left : Int, top : Int, width : Int, height : Int) {
            UIView.animate(withDuration: 0.5) {
                myView.frame.size = CGSize(width: width, height: height)
                myView.center = CGPoint(x: left-(width/2), y: height-(height/2));
            }
        }

use:

B4X:
animateView(myView: cube1, left: 50, top: 100, width: 200, height: 200)

xcode has lots of possibilities but i must say i like b4i ide more. :)

i had to buy a new 24" for my mac mini and upgrade to SSD because xcode runs really slow on normal HD and if you want to see the designer (StoryBoard) and your code at the same time you need a big screen with high resolution. its not like b4x has 2 windows where i can use 2 screens. this is much much comfortable (using 2 screens then only 1).

i have 4 screen on my desk. 2 for b4a/b4j and 2 for b4i. anyway i think that it is important to know also the native language that is why i am learning this days swift and JAVA to have more control on my b4x projects.
 
Top