Skip to content

alchimya/iOS-Marquee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

iOS-Marquee

A simple implementation of a marquee effect

How to implement an h-scrolling

Within this project/tutorial I used a very simple implementation to achive an horizontal scolling.
A scrolling motion is a geometric tranlsation on the x-axis, so if you want to scroll (translate) to the left, you have to subtract an arbitrary value from the current x position, otherwise if you want to scrollto the right you have to add this value.

ScreenShot

When the scrolling view will get to the limit of the right or left side of the graphic context (screen) we have to move it to the opposite side of the scolling direction.

ScreenShot

How to use

To implement a scrolling effect, you have to create an instance of the class L3SDKMarqueeView and initialize it with one of the following factory methods:

-(instancetype)initWithFrame:(CGRect)frame
                  andContent:(UIView*)content
                andDirection:(L3SDKMarqueeDirection)direction
                    andSpeed:(float)speed;

-(instancetype)initWithFrame:(CGRect)frame
                  andContent:(UIView*)content
                andDirection:(L3SDKMarqueeDirection)direction
                    andSpeed:(float)speed
                 andAutoPlay:(BOOL)autoPlay;

where:

  • frame:is the frame of the container marquee view.
  • content:is the view that you want to applay the scrolling. It, for instance, can be an UILabel, but also a view with subviews (e.g. UIImageView).
  • direction:the direction of the scroll and it can assume the values of L3SDKMarqueeDirectionRight or L3SDKMarqueeDirectionLeft.
  • speed:is the scroll speed (duration of the view animation).


The L3SDKMarqueeView interface exposes also other two methods that allow to stop and start/resume the scrolling: ```objectivec -(void)play; -(void)stop; ``` ![ScreenShot](https://raw.github.com/alchimya/iOS-Marquee/master/screenshots/iOS-Marquee.gif)

Here an example of how to use the L3SDKMarqueeView class.

//deinfes an UILabel
UILabel*leftMarqueeLabel=[[UILabel alloc]initWithFrame:
                          CGRectMake(
                                    self.view.bounds.size.width,
                                    0,
                                    self.view.bounds.size.width/2,
                                    50)
                          ];
leftMarqueeLabel.textColor=[UIColor whiteColor];
leftMarqueeLabel.text=@"marquee scrolling to the left side";
leftMarqueeLabel.font=[UIFont fontWithName:@"Verdana" size:40];
[leftMarqueeLabel sizeToFit];

//init a L3SDKMarqueeView instance with a label
self.leftMarqueeView=[[L3SDKMarqueeView alloc] initWithFrame:
                  CGRectMake(0, self.view.bounds.size.height/4, self.view.bounds.size.width, 50)
                                              andContent:leftMarqueeLabel
                                            andDirection:L3SDKMarqueeDirectionLeft
                                                andSpeed:0.5];
    
self.leftMarqueeView.backgroundColor=[UIColor redColor];
[self.view addSubview:self.leftMarqueeView];

About

A simple implementation of a marquee effect

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published