ios动态效果实现翻页_iOS图片界面翻页切换效果

本文实例为大家分享了iOS图片界面翻页切换的具体代码,供大家参考,具体内容如下

先看效果:

下面贴代码:

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

}

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值