Scrolling UILabel like a marquee in a subview

后端 未结 4 706
-上瘾入骨i
-上瘾入骨i 2020-12-17 05:47

I have a UILabel in the main view with text - \"Very Very long text\". The proper width to this would be 142, but i\'ve shortened it to 55.

Basical

4条回答
  •  庸人自扰
    2020-12-17 06:39

    You add In your view scrollview and add this label in your scroll view .Use this code

     scroll.contentSize =CGSizeMake(100 *[clubArray count],20);
    NSString  *bname;
    bname=@"";
    for(int i = 0; i < [clubArray count];  i++)
    {
        bname = [NSString stringWithFormat:@"%@  %@ ,",bname,[[clubArray objectAtIndex:i] objectForKey:@"bottle_name"]];
        [bname retain];
    
    }
    UILabel *lbl1 = [[UILabel alloc] init];
    [lbl1 setFrame:CGRectMake(0,5,[clubArray count]*100,20)];
    lbl1.backgroundColor=[UIColor clearColor];
    lbl1.textColor=[UIColor whiteColor];
    lbl1.userInteractionEnabled=YES;    
    [scroll addSubview:lbl1];
    lbl1.text= bname;
    

    This is implemented code.Thanks

提交回复
热议问题