【问题标题】:Marquee effect in uiimageview iPhoneuiimageview iPhone中的选框效果
【发布时间】:2012-09-27 12:54:56
【问题描述】:

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

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

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

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

请帮忙

【问题讨论】:

    标签: iphone uiimageview marquee


    【解决方案1】:
    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];
    

    【讨论】:

    • 不,它不对,它会在第二个到来之前消失第一个图像。
    • @MonishBansal 只要确保云的起点和终点都在屏幕外。
    • 如何更改尺寸?
    【解决方案2】:

    这样做:

    -(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)];
                     }];
     }
    

    【讨论】:

    • 不,这不对。它会在第二个到来之前停止第一个图像。
    【解决方案3】:

    试试这个例子,它适用于 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];
    }
    

    【讨论】:

    • 是的,它适用于 uilabel。但是当我使用 uiimage 时。第一个循环完美无缺,但第二个第一个会消失。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多