iOS Question Change transition duration

Pooya1

Active Member
Licensed User
Hello
According below code,we can show page with custom transition and it is working good
But i cannot change transition's duration runtime or with RunMethod
Please refactor this ShowPage precedure for support duration
Thanks
B4X:
'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
'13 = fade
'14 = push
'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"
        Case 13
            TransitionType = "fade"
        Case 14
            TransitionType = "push"

    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
 

Pooya1

Active Member
Licensed User
I can solve it guys
Change
Public Sub ShowPage(NavigationControl As NavigationController,PageToShow As Page,TransType As Int, Direction As Int)
To
Public Sub ShowPage(NavigationControl As NavigationController,PageToShow As Page,TransType As Int, Direction As Int,Duration As Float)

And Change
no.RunMethod("trans:::",Array(NavigationControl,TransitionType,FromDirection))
To
no.RunMethod("trans::::",Array(NavigationControl,TransitionType,FromDirection,Duration))

And use below inline code
B4X:
#if OBJC

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

#End If
 
Upvote 0
Top