加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在imageview中淡出幻灯片. xCode 4.2

发布时间:2020-12-14 17:49:16 所属栏目:百科 来源:网络整理
导读:我正在尝试在使用淡入淡出效果的imageview中制作幻灯片. 到目前为止我做到了这一点: - (void)viewDidLoad{ [super viewDidLoad]; animationView = [[UIImageView alloc] initWithFrame:self.view.frame]; animationView.animationImages = [NSArray arrayWi
我正在尝试在使用淡入淡出效果的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];    
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读