The simple implementation of IOS is similar to the novel reading sliding paging effect

Source: Internet
Author: User

Nonsense not much to say on the code we're going to create a Uiviewcontroller

typedef Enum:nsuinteger {

Fade = 1,//fade in

Push,//push

Reveal,//Uncover

Movein,//cover

Cube,//Cube

Suckeffect,//Suck

Oglflip,//Flip

Rippleeffect,//Ripple

Pagecurl,//page

Pageuncurl,//Reverse page

Camerairishollowopen,//Open lens

Camerairishollowclose,//Turn off the lens

Curldown,//Page Down

Curlup,//PAGE UP

Flipfromleft,//left Flip

Flipfromright,//Right Flip

} Animationtype;

Various paging effects.

@interface Viewcontroller () {

Nsinteger _count;//turn to the first few pages

Total number of Nsinteger _sum;//pages

Nsarray *_arr;//Set Page background color

}


-(void) Viewdidload {

[Super Viewdidload];

_sum = 20;

Self.view.backgroundColor = [Uicolor Whitecolor];

_arr = @[[uicolor redcolor],[uicolor greencolor],[uicolor Bluecolor]];

NSLog (@ "------------------?------------page%ld", (long) _count);

[Self rootviewadduiswipegesturerecognizer];

}


-(void) rootviewadduiswipegesturerecognizer{

Uiswipegesturerecognizer *FROMRIGHTSWIP = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector ( NextPage)];

Fromrightswip.direction = Uiswipegesturerecognizerdirectionleft;

[Self.view ADDGESTURERECOGNIZER:FROMRIGHTSWIP];

Uiswipegesturerecognizer *FROMLEFTSWIP = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector ( Forwardpage)];

Fromleftswip.direction = Uiswipegesturerecognizerdirectionright;

[Self.view ADDGESTURERECOGNIZER:FROMLEFTSWIP];

}

Implementing Sliding Events

-(void) nextpage{

Self.view.backgroundColor = _arr[arc4random ()%3];

if (_count<_sum-1) {

NSString *subtypestring;

subtypestring = Kcatransitionfromright;

[Self transitionwithtype:@ "push" withsubtype:subtypestring ForView:self.view];

_count = _count + 1;

} else {

_count = _sum-1;

}

NSLog (@ "+++++++++++++++++++?+++++++++++++++ page%ld", (long) _count);

}


-(void) forwardpage{

Self.view.backgroundColor = _arr[arc4random ()%3];

if (_count>0) {

NSString *subtypestring;

subtypestring = Kcatransitionfromleft;

[Self transitionwithtype:@ "push" withsubtype:subtypestring ForView:self.view];

_count = _count-1;

} else {

_count = 0;

}

NSLog (@ "------------------?------------page%ld", (long) _count);

}

#pragma mark Catransition Animation implementation

/**

* Animation effect implementation

*/

-(void) Transitionwithtype: (NSString *) type Withsubtype: (NSString *) subtype Forview: (UIView *) Rootview {

Creating Catransition Objects

Catransition *animation = [catransition animation];

Animation.duration = 0.5f;

Animation.type = type;

if (subtype!= nil) {

Animation.subtype = subtype;

}

Animation.timingfunction = Uiviewanimationoptioncurveeaseinout;

[Rootview.layer addanimation:animation forkey:@ "animation"];

}

-(void) didreceivememorywarning {

[Super didreceivememorywarning];

}

Related Article

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.