Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在我的应用程序中使用marquee?_Iphone_Objective C_Xcode_Cocoa Touch - Fatal编程技术网

Iphone 如何在我的应用程序中使用marquee?

Iphone 如何在我的应用程序中使用marquee?,iphone,objective-c,xcode,cocoa-touch,Iphone,Objective C,Xcode,Cocoa Touch,我为如下所示的marquee编写了代码--- 这是可行的,但不能满足我的需要。。。 实际上,文本不是以循环形式移动的, 我希望如果字符串长度>60,那么选取框开始并附加字符串 请帮我解决这个问题。。 提前谢谢。给你 这是另一个 我希望你的问题会得到解决 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:YES]; //NSTimer *timer=[[NSTimer alloc] initWithFireD

我为如下所示的marquee编写了代码---

这是可行的,但不能满足我的需要。。。 实际上,文本不是以循环形式移动的, 我希望如果字符串长度>60,那么选取框开始并附加字符串

请帮我解决这个问题。。 提前谢谢。

给你

这是另一个

我希望你的问题会得到解决

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