Coder Social home page Coder Social logo

shevakuilin / skautoscrolllabel Goto Github PK

View Code? Open in Web Editor NEW
78.0 1.0 10.0 114 KB

Automatically scrolling UILabel with both horizontal/vertical MARQUEE effects and gradient gradients on the edges. Gradient fading is used on the edge of the scroll to solve the problem of the hard edges of the rolling edge. The overall effect is a natural and easy to use.

License: MIT License

Objective-C 97.52% Ruby 2.48%
ios ios-ui uilabel autoscrolllabel objective-c lightweight multi-directional-scrolling applying-background-switching scroll-pause-continue gradient-effect

skautoscrolllabel's Introduction

SKAutoScrollLabel

Automatically scrolling UILabel with both horizontal/vertical MARQUEE effects and gradient gradients on the edges.Gradient fading is used on the edge of the scroll to solve the problem of the hard edges of the rolling edge. The overall effect is a natural and easy to use.

Feature

  • Supports automatic scrolling in four directions: up, down, left, and right.
  • Freely controllable scroll pause/continue.
  • Scrolling behavior is not interrupted when applying background switching.
  • Lightweight, at least one line of initialization code is required to create.
  • Control gradient effect is softer and more natural.
  • Fully comment and instructions.

Using effect

How to use

Step 1: Execute git clone [email protected]:shevakuilin/SKAutoScrollLabel.git,then view Example.

Step 2: Copy the SKAutoScrollLabel from the directory directly into your project, or add pod 'SKAutoScrollLabel' to the Podfile.

Step 3: Reference header file #import <SKAutoScrollLabel/SKAutoScrollLabel.h>

Installation

Created by code

// Scroll from right to left
SKAutoScrollLabel *scrollLabel = [[SKAutoScrollLabel alloc] initWithTextContent:@"Fly me to the moon.Let me play among the stars.Let me see what spring is like on Jupiter and Mars.In other words, hold my hand.In other words, baby, kiss me." direction: SK_AUTOSCROLL_DIRECTION_LEFT];
scrollLabel.backgroundColor = [UIColor orangeColor];
scrollLabel.textColor = [UIColor whiteColor];
// ... other settings

Created by storyboard

// Set the object's class to SKAutoScrollLabel in the storyboard
@property (weak, nonatomic) IBOutlet SKAutoScrollLabel *scrollLabel;

// Scroll from right to left
self.scrollLabel.textContent = @"Fly me to the moon.Let me play among the stars.Let me see what spring is like on Jupiter and Mars.In other words, hold my hand.In other words, baby, kiss me.";
self.scrollLabel.direction = SK_AUTOSCROLL_DIRECTION_LEFT;
self.scrollLabel.backgroundColor = [UIColor orangeColor];
self.scrollLabel.textColor = [UIColor whiteColor];
// ... other settings

Parameter meaning

  • direction scrolling direction

    • SK_AUTOSCROLL_DIRECTION_RIGHT // Scroll from left to right
    • SK_AUTOSCROLL_DIRECTION_LEFT // Scroll from right to left
    • SK_AUTOSCROLL_DIRECTION_TOP // Scroll from bottom to top
    • SK_AUTOSCROLL_DIRECTION_BOTTOM // Scroll from top to bottom
  • pointsPerFrame The distance each frame moves.The default vaule is 1.0f.

  • labelSpacing The spacing of each scrolling label.The default vaule is 20.

  • textContent Plain text content.

  • attributedTextContent Rich text content.

  • textColor Plain text color.

  • font Plain text font.

  • textAlignment Plain text alignment.

  • enableFade Default YES. Enable gradients of lable boundaries to fade.

Control Method

- (void)pauseScroll; // Pause scrolling animation being played.
- (void)continueScroll; // Make a paused scrolling animation continue playing.

简述

SKAutoScrollLabel是一个同时支持水平/垂直两种类型的“跑马灯”效果的自动滚动UILabel。在滚动的边缘使用了梯度褪色来解决滚动边缘生硬的效果问题,总体效果呈现出混然天成的感觉,并且使用简单方便。如果你觉得还不错,请star支持一下吧~

特性

  • 支持上、下、左、右四个方向的自动滚动
  • 随时可自由控制的滚动暂停 / 继续
  • 应用前后台切换时,滚动行为不会被中断
  • 轻量级,最少仅需一行初始化代码即可完成创建
  • 控件梯度渐变效果柔和,更自然
  • 完善的注释与说明

效果图

如何开始

1.git clone [email protected]:shevakuilin/SKAutoScrollLabel.git,查看示例工程 Example

2.直接将目录下的 SKAutoScrollLabel 拷贝到你的工程中,或在Podfile文件中添加 pod 'SKAutoScrollLabel'

3.引用头文件 #import <SKAutoScrollLabel/SKAutoScrollLabel.h>

初始化

通过代码创建

// 创建一个从右向左滚动的,背景颜色为橙色,字体颜色为白色的滚动 Label
SKAutoScrollLabel *scrollLabel = [[SKAutoScrollLabel alloc] initWithTextContent:@"你指尖跃动的电光, 是我此生不灭的信仰! 唯我超电磁炮永世长存!! 哔哩哔哩(゜-゜)つロ干杯~-bilibili" direction: SK_AUTOSCROLL_DIRECTION_LEFT];
scrollLabel.backgroundColor = [UIColor orangeColor];
scrollLabel.textColor = [UIColor whiteColor];
// ... 其他设置

通过 storyboard 创建

// 在 storyboard 中将对象的类设置为 SKAutoScrollLabel
@property (weak, nonatomic) IBOutlet SKAutoScrollLabel *scrollLabel;

// 创建一个从右向左滚动的,背景颜色为橙色,字体颜色为白色的滚动 Label
self.scrollLabel.textContent = @"你指尖跃动的电光, 是我此生不灭的信仰! 唯我超电磁炮永世长存!! 哔哩哔哩(゜-゜)つロ干杯~-bilibili";
self.scrollLabel.direction = SK_AUTOSCROLL_DIRECTION_LEFT;
self.scrollLabel.backgroundColor = [UIColor orangeColor];
self.scrollLabel.textColor = [UIColor whiteColor];
// ... 其他设置

基本参数

  • direction 滚动方向

    • SK_AUTOSCROLL_DIRECTION_RIGHT // 从左向右滚动, 默认选项
    • SK_AUTOSCROLL_DIRECTION_LEFT // 从右向左滚动
    • SK_AUTOSCROLL_DIRECTION_TOP // 从下向上滚动
    • SK_AUTOSCROLL_DIRECTION_BOTTOM // 从上向下滚动
  • pointsPerFrame 每帧移动的距离。默认值为1.0f。

  • labelSpacing 每个滚动标签的间距。默认值为20。

  • textContent 普通文本内容

  • attributedTextContent 富文本内容

  • textColor 文本颜色

  • font 字体

  • textAlignment 文字对齐

  • enableFade 开关梯度渐变,默认开启

控制方法

- (void)pauseScroll; // 暂停滚动
- (void)continueScroll; // 继续滚动

感谢你花时间阅读以上内容, 如果这个项目能够帮助到你,记得告诉我

Email: [email protected]

skautoscrolllabel's People

Contributors

shevakuilin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

skautoscrolllabel's Issues

两个优化建议

首先感谢你的贡献

还有两个优化建议
1、当字符展示长度小于label的frame width的时候,不需要滚动显示。
2、提供reset功能,当pausescroll的时候,我希望文本按照设定的textAlignment来显示

NSRunLoopCommonModes

  • (void)creatDisplayLink {
    self.displayLinke = [CADisplayLink displayLinkWithTarget:self selector:@selector(processDisplayLink)];
    [self.displayLinke addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.