iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在imageview中淡出幻灯片. xCode 4.2大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我正在尝试在使用淡入淡出效果的imageview中制作幻灯片. 到目前为止我做到了这一点: - (void)viewDidLoad { [super viewDidLoad]; animationView = [[UIImageView alloc] initWithFrame:self.view.frame]; animationView.animationImages
我正在尝试在使用淡入淡出效果的imageview中制作幻灯片.

到目前为止我做到了这一点:

- (void)viewDidLoad
{
    [super viewDidLoad];
    animationView = [[UIImageView alloc] initWithFrame:self.view.frame];
    animationView.animationImages = [NSArray arrayWithObjects:   
                                     [UIImage imagenamed:@"photo1.jpg"],[UIImage imagenamed:@"photo2.jpg"],[UIImage imagenamed:@"photo3.jpg"],nil];

    animationView.animationDuration = 5;
    animationView.animationRepeatCount = 0;
    [animationView startAnimaTing];
    [self.view addSubview:animationView];
}

图像确实一个一个地出现,在5秒的延迟中,我现在想要的是每次出现图像时使它们淡入和淡出,对此有何建议?

在此先感谢您的帮助

解决方法

我试图做类似的事情.我做的是设置一个计时器,在UIImageView上调用UIView transitionWithView,它通过我的幻灯片照片数组递增.

- (void)viewDidLoad{
[super viewDidLoad];
self.welcomePhotos = [NSArray arrayWithObjects:@"welcome_1.png",@"welcome_2.png",@"welcome_3.png",nil];
self.imageView1.image = [UIImage imagenamed:[self.welcomePhotos objectATindex:0]];
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self SELEctor:@SELEctor(transitionPhotos) userInfo:nil repeats:YES];
}


-(void)transitionPhotos{

if (photoCount < [self.welcomePhotos count] - 1){
    photoCount ++;
}else{
    photoCount = 0;
}
[UIView transitionWithView:self.imageView1
                  duration:2.0
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{ self.imageView1.image = [UIImage imagenamed:[self.welcomePhotos objectATindex:photoCount]]; }
                completion:NULL];    
}

大佬总结

以上是大佬教程为你收集整理的在imageview中淡出幻灯片. xCode 4.2全部内容,希望文章能够帮你解决在imageview中淡出幻灯片. xCode 4.2所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。