3

其实我想在objective.I做动画。我已经添加了imageview(子类)列表来查看并将所有imageView存储在数组中,如下所示

    CustomImageView *imageView = [[CustomImageView alloc]init];
    imageView.tag = index;
    imageView._x = (i%4)*150;
    imageView._y = int(i/4)*150;
    imageView.vx = 0;
    imageView.vy = 0;
    imageView.dragging = false;
    imageView.frame = CGRectMake(imageView._x, imageView._y, imageView._width, imageView._height);
    imageView.userInteractionEnabled = YES;

    UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapGesture:)];

    tapGesture1.numberOfTapsRequired = 1;

    [tapGesture1 setDelegate:self];

    [imageView addGestureRecognizer:tapGesture1];

    [self.view addSubview:imageView];

    [imageViewsArray  addObject:imageView];

我们可以通过以下代码访问更改特定 imageView 属性(子类属性)的值吗

UIImageView * imageView = [imageViewsArray objectAtIndex:tag];
imageView.dragging = true;
imageView.vx = 0;
imageView.vy = 0;
4

1 回答 1

0

嗯...嗯,是的,我认为它会起作用。

不太确定您在这里尝试做什么(特别是考虑到您的 x/y 基于索引),但通常不是为每个图像创建一个 CustomImageView (然后您必须将其插入到视图层次结构中),也许将图像(即 UIImage)加载到您的数组中,然后将它们交换到您的 CustomImageView 中。

于 2016-01-19T20:21:31.123 回答