gpt4 book ai didi

ios - 自动淡入和淡出多个图像

转载 作者:行者123 更新时间:2023-12-01 19:16:44 25 4
gpt4 key购买 nike

我在这里,需要帮助。
我使用 Storyboard并希望自动淡入淡出照片显示。
问题是我有 10 张图像,现在不知道如何以编程方式制作它。
我希望有人能帮助我。

最佳答案

  mainImageView = [[UIImageView alloc]init];
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"third.png"],[UIImage imageNamed:@"fourth.png"],[UIImage imageNamed:@"fifth.png"],[UIImage imageNamed:@"sixth.png"],[UIImage imageNamed:@"seventh.png"],[UIImage imageNamed:@"eight.png"],[UIImage imageNamed:@"nine.png"],[UIImage imageNamed:@"ten.png"], nil]; //add your images here
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(crossfade) userInfo:nil repeats:YES];
[mainImageView setFrame:CGRectMake(50,50,100,100)];
mainImageView.animationImages = animationArray; //mainImageView is imageview
mainImageView.animationDuration = 10;
mainImageView.animationRepeatCount = 0;
[mainImageView startAnimating];


[self.view addSubview:mainImageView];


[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)crossfade {
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
mainImageView.alpha = !mainImageView.alpha;
}completion:^(BOOL done){
//
}];
}

关于ios - 自动淡入和淡出多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12838899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com