iOS图片界面翻页切换效果
程序员文章站
2024-02-15 09:21:04
先看效果:
下面贴代码:
#import "viewcontroller.h"
@interface viewcontroller ()...
先看效果:
下面贴代码:
#import "viewcontroller.h" @interface viewcontroller () @property (weak, nonatomic) iboutlet uiimageview *backgroundview; @property (strong,nonatomic) nsarray *array; @end @implementation viewcontroller -(nsarray *)array { if (_array == nil) { uiimage *image1 = [uiimage imagenamed:@"01.jpg"]; uiimage *image2 = [uiimage imagenamed:@"02.jpg"]; _array = @[image1,image2]; } return _array; } - (void)viewdidload { [super viewdidload]; self.backgroundview.image = self.array[0]; // do any additional setup after loading the view, typically from a nib. } -(void)changeimage { if (self.backgroundview.image == self.array[0]) { self.backgroundview.image = self.array[1]; }else { self.backgroundview.image = self.array[0]; } } - (ibaction)pushclick:(id)sender { [self changeimage]; catransition *transtion = [[catransition alloc] init]; transtion.type = @"push"; transtion.subtype = kcatransitionfrombottom; transtion.startprogress = 0.5; transtion.endprogress = 0.8; [self.view.layer addanimation:transtion forkey:nil]; } /* 效果有好多种,上面代码只贴出了其中一种,如果需要其他效果,只需要将 transtion.type = @"push";中的type改一下就行。 比如: transtion.type = @"fade"; type的类型还有以下几种: fade,reveal,movein,cube,suckeffect,oglflip,rippleeffect,pagecurl,pagecurl,camerairishollowopen,camerairishollowclose,pageuncurl,pagecurl,pagecurl,pagecurl */ - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can be recreated. }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。