ios UIImageView添加图片动画效果,添加了手势之后,依然没有反应的解决方法

来源:互联网 发布:mysql.sock不见了 编辑:程序博客网 时间:2024/04/27 21:36

ios UIImageView添加图片动画效果,添加了手势之后,依然没有反应的解决方法

UIImageView添加图片动画效果

[super viewDidLoad];    imgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];    NSMutableArray *arrayImg=[NSMutableArray array];    [arrayImg addObject:[UIImage imageNamed:@"1.png"]];    [arrayImg addObject:[UIImage imageNamed:@"2.png"]];    [arrayImg addObject:[UIImage imageNamed:@"3.png"]];    [arrayImg addObject:[UIImage imageNamed:@"4.png"]];    [arrayImg addObject:[UIImage imageNamed:@"5.png"]];    [arrayImg addObject:[UIImage imageNamed:@"6.png"]];    [imgView setAnimationImages:arrayImg];    [imgView setAnimationDuration:1];    [imgView setAnimationRepeatCount:20];    [imgView startAnimating];   // [imgView setUserInteractionEnabled:YES]; //需要设置该属性可以实现人机交互    [self.view addSubview:imgView];

比如在UIImageView中添加手势

UITapGestureRecognizer *sigleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changeBack:)];    [imgView addGestureRecognizer:sigleTap];

-(void)changeBack:(id)sender{    [self.view setBackgroundColor:[UIColor groupTableViewBackgroundColor]];}
需要设置该属性可以实现人机交互

[imgView setUserInteractionEnabled:YES];



原创粉丝点击