3

如何在 UIImage 中实现选取框效果动画。

我有一张云的图像(320 * 480)。我需要从右向左连续动画,没有任何滞后和消失。下面是一个html示例。

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

从上数第二个(连续滚动文本:)。

请帮忙

4

3 回答 3

2
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];
于 2012-09-27T04:26:35.180 回答
1

做这个:

-(void)marqueeEffect
{
  imgView.frame = CGRectMake(self.view.frame.origin.y,50,320,480); //right frame
  //increase time duration as per requirement
  [UIView animateWithDuration:3.0
                      delay: 0.0
                    options: UIViewAnimationCurveEaseOut
                 animations:^{

                      imgView.frame = CGRectMake(-imgview.frame.size.width,50,320,480); //left frame
                 }
                 completion:^(BOOL finished){
                      [self performSelector:@selector(marqueeEffect)];
                 }];
 }
于 2012-09-27T04:25:55.723 回答
0

试试这个例子,它适用于 UILABEL:

int x;
@synthesize label;
- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

    label=[[UILabel alloc]initWithFrame:CGRectMake(300, 400, 150, 30)];
    label.text=@"WWW.SONGS.PK";
    label.backgroundColor=[UIColor clearColor];
    x=300;

    [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(clickme) userInfo:nil repeats:YES];

}

-(void)clickme
{
    x--;
    label.frame=CGRectMake(x, 400, 150, 30);
    if( x==-150)
    {
        x=300;
    }
    [self.view addSubview:label];
}
于 2012-09-27T04:51:02.507 回答