iOS Development-Create Push Segue Animation without Uinavigationcontroller

Source: Internet
Author: User

Apple offers three ways to storyboard segue:push,modal,custom .

The push Segue is a predefined jump method for the system,

In order for it to work properly, we must also load the Uinavigationcontroller.

Sometimes we don't want to see Uinavigation bar, we can use modal segue.

modal Segue has four ways to jump: Cover Vertical, Flip horizontal, cross dissolve and Partial Curl.

If the way we want to jump is different from these four ways, we can use the custom jump mode named Segue.

Here is a sample that implements the custom Segue :

1. Create a Uistoryboardsegue subclass

2. Overloaded-(void) Perform method

1- ( void) perform
2{
3Uiviewcontroller *desviewcontroller = (Uiviewcontroller *) Self.destinationviewcontroller;
4
5UIView *srcview = [(Uiviewcontroller *) Self.sourceviewcontroller view];
6UIView *desview = [Desviewcontroller view];
7
8Desview.transform = Srcview.transform;
9Desview.bounds = Srcview.bounds;
Ten
One if(islandscapeorientation)
A{
- if(Isdismiss)
-{
theDesview.center = Cgpointmake (srcview.center.x, srcview.center.y-srcview.frame.size.height);
-}
- Else
-{
+Desview.center = Cgpointmake (srcview.center.x, srcview.center.y + srcView.frame.size.height);
-}
+}
A Else
at{
- if(Isdismiss)
-{
-Desview.center = Cgpointmake (Srcview.center.x-srcview.frame.size.width, SRCVIEW.CENTER.Y);
-}
- Else
in{
-Desview.center = Cgpointmake (srcview.center.x + srcView.frame.size.width, srcview.center.y);
to}
+}
-
the
*UIWindow *mainwindow = [[UIApplication sharedapplication].windows Objectatindex: 0];
$[MainWindow Addsubview:desview];
Panax Notoginseng
- // slide Newview over Oldview and then remove Oldview
the [UIView animatewithduration: 0.3
+animations:^{
ADesview.center = Cgpointmake (srcview.center.x, SRCVIEW.CENTER.Y);
the
+ if(islandscapeorientation)
-{
$ if(Isdismiss)
${
-Srcview.center = Cgpointmake (srcview.center.x, srcview.center.y + srcView.frame.size.height);
-}
the Else
-{
WuyiSrcview.center = Cgpointmake (srcview.center.x, srcview.center.y-srcview.frame.size.height);
the}
-}
Wu Else
-{
About if(Isdismiss)
${
-Srcview.center = Cgpointmake (srcview.center.x + srcView.frame.size.width, srcview.center.y);
-}
- Else
A{
+Srcview.center = Cgpointmake (Srcview.center.x-srcview.frame.size.width, SRCVIEW.CENTER.Y);
the}
-}
$}
thecompletion:^ (BOOL finished) {
the // [Desview Removefromsuperview];
the [Self.sourceviewcontroller Presentmodalviewcontroller:desviewcontroller Animated:no];
the}];

-  }

In Viewcontroller, the overloaded Prepareforsegue method

1- ( void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: ( ID) Sender
2{
3Horizontalslidesegue *s = (Horizontalslidesegue *) segue;
4S.isdismiss = NO;
5
6 if(Uideviceorientationislandscape ([Uidevice currentdevice].orientation))
7{
8S.islandscapeorientation = YES;
9}
Ten Else
One{
AS.islandscapeorientation = NO;
-}

-  }

3. Choose the custom Segue setting Segue class: Customsegue (Our custom Class)

4. Call Segue Using code:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.