Ios 我想显示不同的图像连续无需用户触摸按钮
当用户触摸按钮时,下面的代码显示图像。我想在没有用户触摸按钮的情况下连续显示不同的图像,如熊、猫、牛、狗。有人能帮我吗Ios 我想显示不同的图像连续无需用户触摸按钮,ios,objective-c,Ios,Objective C,当用户触摸按钮时,下面的代码显示图像。我想在没有用户触摸按钮的情况下连续显示不同的图像,如熊、猫、牛、狗。有人能帮我吗 NSMutableArray *dashBoy = [NSMutableArray array]; for (i = 1; i<= 12; i++) { butterfly = [NSString stringWithFormat:@"bear_%d.png", i]; if ((image = [UIImage imageNamed:butterf
NSMutableArray *dashBoy = [NSMutableArray array];
for (i = 1; i<= 12; i++)
{
butterfly = [NSString stringWithFormat:@"bear_%d.png", i];
if ((image = [UIImage imageNamed:butterfly]))
[dashBoy addObject:image];
}
[stgImageView setAnimationImages:dashBoy];
[stgImageView setAnimationDuration:4.0f];
[stgImageView setAnimationRepeatCount:2];
[stgImageView startAnimating];
试试这个。。
创建两个实例对象,如
NSMutableArray*图像阵列;和UIImageView*动画图像视图
您可以执行以下操作:- 首先,创建一个UIImageView属性,如下所示
@property (nonatomic,weak) IBOutlet UIImageView *imageView; //Also connect it with storyboard or xib.
然后你可以写下iAction如下:-
- (IBAction)startTap:(id)sender {
[self.imageView setAnimationDuration:1.0f]; //You could change the duration for making animation fast or slow.
[self.imageView setAnimationImages:imageArray]; //imageArray is NSArray of images of which you want to show slide show.
[self.imageView startAnimating]; //simply to start animation.
}
- (IBAction)stopTap:(id)sender {
[self.imageView stopAnimating]; //To stop animation.
}
你需要证明你为解决这个问题做了一些努力。你做了什么研究?请不要把代码放在评论里,很难阅读。编辑你的问题,包括代码和你所做的解释。为什么否决投票?你能告诉我理由@down voter吗
@property (nonatomic,weak) IBOutlet UIImageView *imageView; //Also connect it with storyboard or xib.
- (IBAction)startTap:(id)sender {
[self.imageView setAnimationDuration:1.0f]; //You could change the duration for making animation fast or slow.
[self.imageView setAnimationImages:imageArray]; //imageArray is NSArray of images of which you want to show slide show.
[self.imageView startAnimating]; //simply to start animation.
}
- (IBAction)stopTap:(id)sender {
[self.imageView stopAnimating]; //To stop animation.
}