2011-07-20 11 views
0

私は、この作品どのように私は自分のアプリケーションでのマーキーを使用することができますか?

- (void)viewDidAppear:(BOOL)animated { 

    [super viewDidAppear:YES]; 
    //NSTimer *timer=[[NSTimer alloc] initWithFireDate:nil interval:.5 target:self selector:@selector(marqueDisplay) userInfo:nil repeats:YES]; 
    [NSTimer scheduledTimerWithTimeInterval:7.0 
            target:self 
            selector:@selector(marqueDisplay) 
            userInfo:nil 
            repeats:YES]; 

} 

-(void)marqueDisplay 
{ 
    NSString *theMessage = @"Hello, my name is Enigo Montoya. You killed my father, prepare to die"; 
    NSUInteger length = [theMessage length]; 
    NSLog(@"%d",length); 
    if (length>69) {  
    messageSize = [theMessage sizeWithFont:[UIFont systemFontOfSize:14.0]]; 
    messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, messageSize.width, 19)]; //x,y,width,height 
    [messageView setClipsToBounds:YES]; // With This you prevent the animation to be drawn outside the bounds. 
    [self.view addSubview:messageView]; 

    lblTime = [[UILabel alloc] initWithFrame:CGRectMake(-400, 0, messageSize.width, 19)]; //x,y,width,height 
    [lblTime setBackgroundColor:[UIColor darkGrayColor]]; 
    lblTime.font = [UIFont systemFontOfSize:14]; 
    [lblTime setText:theMessage]; 
    [lblTime setTextAlignment:UITextAlignmentLeft]; 
    //lblTime.frame = CGRectMake(0, 0, messageSize.width, 19); //x,y,width,height 
    [messageView addSubview:lblTime]; 

    float duration = messageSize.width/60; // This determines the speed of the moving text. 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:duration]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:messageView cache:YES]; 
    lblTime.frame = CGRectMake(messageSize.width, 0, messageSize.width, 19); //x,y,width,height 
    [UIView commitAnimations]; 
    } 
} 

---以下に示しマーキーのためのコードを書いたが、これは私が、もし文字列の長さが欲しい 、 が実際にテキストがループ状に動いていない...私の必要性を満たしていません> 60は、起動して、文字列を追加マーキー。

Plzを..事前に おかげでこの問題を解決するために私を助けて。

答えて

関連する問題