ios界面切换效果实例代码
来源:爱站网时间:2022-08-09编辑:网友分享
本篇文章主要为大家讲述了关于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.
}
以上就是关于ios界面切换效果实例代码的全部内容了,不知道朋友们都看明白了没有,想要获取更多不同类型的技术文章内容,关注爱站技术频道网站即可。
上一篇:iOS有哪些延迟执行的方式
下一篇:ios请求超时如何处理
