Search code examples
iphoneuiimageviewmarquee

Marquee effect in uiimageview iPhone


How can I implement marquee effect animation in UIImage.

I have a image of cloud (320*480). I need to animation it continuously left from right without any lagging and disappearing. Below is a sample of html.

http://www.quackit.com/html/codes/html_marquee_code.cfm

2nd from top(Continuous scrolling text:).

Please help


Solution

  • UIImage *clouds = [UIImage imageNamed:@"Clouds"];
    UIImageView *cloudView = [[UIImageView alloc] initWithImage:clouds];
    CGRect origin = CGRectMake(320, 0, clouds.size.width, clouds.size.height);
    CGRect destination = CGRectMake(0, 0, clouds.size.width, clouds.size.height);
    cloudView.frame = origin;
    [self.view addSubview:cloudView];
    [UIView animateWithDuration:5 delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear animations:^{
        cloudView.frame = destination;
    } completion:nil];