0
我想連續從左到右的方向選取文本。我曾嘗試使用下面的代碼使用,如果任何人有答案,請告訴我,在日Thnx先進.....啓用從左到右連續選框文本
NSString *theMessage = @"Hello, my name is Enigo Montoya. You killed my father, prepare to die";
messageSize = [theMessage sizeWithFont:[UIFont systemFontOfSize:14.0]];
messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, 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(0, 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/30; // 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];
這是什麼問題? –
它會完美選取框只有一次它不會連續選取文本,所以請告訴我 – alfa
我猜'UIViewAnimationTransitionNone'是不夠的。如果我記得好,還有一個重複選項和一個相反的選項? – Larme