iOS图片界面翻页切换效果

2025-05-29 0 26

先看效果:

iOS图片界面翻页切换效果

下面贴代码:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58
#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.

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 iOS图片界面翻页切换效果 https://www.kuaiidc.com/92112.html

相关文章

发表评论
暂无评论