Allowing user interaction during animation

Discussion in 'iOS Programming' started by dantastic, May 11, 2011.

  1. macrumors 6502


    Jan 21, 2011
    So I've these nifty block based animations going at the moment. UIView animateWithDuration..

    This locks the screen completely so I want to set the propertly userInteractionEnabled as it will allow me to accept touches while the animation is ongoing etc.

    Where & how do I set this property??? I've set the userInteractionEnabled = YES to every single view I create but I still can't do anything until the animation has finished...

    - (void) slideLayerDown {
        self.view.userInteractionEnabled = YES;
        UIImage *image = [UIImage imageNamed:@"tst.jpg"];
        baseImageView.image = image;
        baseImageView.userInteractionEnabled = YES;
        slideLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -50, 320, 516)];
        slideLayer.backgroundColor = [UIColor clearColor];
        slideLayer.userInteractionEnabled = YES;
        GradientView *gradientView = [[GradientView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
        gradientView.userInteractionEnabled = YES;
        [slideLayer addSubview:gradientView];
        UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 320, 466)];
        bottomView.backgroundColor = [UIColor whiteColor];
        bottomView.userInteractionEnabled = YES;
        [slideLayer addSubview:bottomView];
        [baseImageView addSubview:slideLayer];
        CGRect frame = slideLayer.frame;
        frame.origin.y = 420;
        [UIView animateWithDuration:60 animations:^(void) {
            slideLayer.frame = frame;
    In the above we have baseImageView sitting directly on top of self.view set up in IB.


Share This Page