iosiphonemarqueeios6.0

moving text from bottom to top like marquee style in iOS application using textView


Moving text like marquee style from bottom to top in iOS application. i have tried this long time using google search but i could not get perfect answer for this question please provide any code for this question. i an new to iOS application.


Solution

  • Try this

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    NSTimer *timer;
    UILabel *label ;
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        timer =[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(scrollText:) userInfo:nil repeats:YES];
        label = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, 250, 20)];
    
        label.text =@"This is a string to be scroll";
        [self.view addSubview:label];
    
    }
    
    -(void)scrollText:(id)parameter{
        if (label.frame.origin.y <= 50) {
            [label setFrame:CGRectMake(label.frame.origin.x, 400, label.frame.size.width, label.frame.size.height)];
        }
        else
        [label setFrame:CGRectMake(label.frame.origin.x, label.frame.origin.y-5, label.frame.size.width, label.frame.size.height)];
    }
    
    @end