How to add selection to a shortcut

I have a shortcut at the top of my UIView. I display some messages on it through an array using a timer. But now I want these messages to be displayed in MARQUEE style. I do not get any way to start.Any source code, usage methods, any style of animation, any other approach. thanks in advance

+3
source share
2 answers

Here is an idea:

  • Set ClipsTables true to the UIView in which your UILabel sits.
  • Then run the UIViewAnimations block (look at the docs for how to use it, very simple)
    • Create a new shortcut with your frame set to a position outside the UIView environment
    • - UIView
    • , .

, , , .

animationDuration , , .

+9

, :

* .

messageView = [[UIView alloc] initWithFrame:CGRectMake(27, 0, 235, 19)];
[messageView setClipsToBounds:YES];//With This you prevent the animation to be drawn outside the bounds.

* UILabel ,

lblTime = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 235, 19)];
[lblTime setBackgroundColor:[UIColor clearColor]];
[messageView addSubview:lblTime];

* , ​​:

- (void)sendNotification:(NSString*)txt{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:3.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:messageView cache:YES];
    [lblTime setText:txt];
    [lblTime setTextAlignment:UITextAlignmentLeft];
    lblTime.frame = CGRectMake(260, 0, 258, 19);
    [UIView commitAnimations];
}
+4

Source: https://habr.com/ru/post/1712446/


All Articles