Giter Club home page Giter Club logo

marquee's Introduction

Marquee(跑马灯)

说一下初衷吧,最初要用到跑马灯功能的时候,也找过一些SDK,但未能找到与我需求很好契合的SDK,主要就是手势滑动后的问题(手势滑动push/pop时候跑马灯出现失灵的状况),目前支持水平 && 上下(正向 && 逆向)滚动,解决push/pop && 前后台切换 && 手势滑动 && 意外中断等情况,希望通过此SDK给予与我有同样需求的童鞋一些帮助。

先上图,看一下是否符合你的场景吧!

Function Description

  1. 轻量级跑马灯
  2. 支持attributedText
  3. 随时获取跑马灯状态
  4. 前/后台切换重新加载
  5. 水平 && 上下(正向 && 逆向)
  6. push/pop || 前后台切换 || 手势返回后自动滚动

How to use

1. podfile

platform:ios, '8.0'

target '*****' do

pod 'JhtMarquee'
        
end

2. 水平:水平向左滚动的跑马灯

a. 简单的集成方式:当成一个普通label使用即可,在初始化方法的时候可以自定义单次滚动时间

/** 初始化
 *  duration: 单次滚动时间
 *  注: duration = 0.0,使用内部自适应计算功能
 */
- (instancetype)initWithFrame:(CGRect)frame withSingleScrollDuration:(NSTimeInterval)duration;

b. 状态自由设置:通过以下方法传入相应的MarqueeState_H枚举值即可

/** 设置跑马灯状态
 *  marqueeState:跑马灯状态(枚举)
 *  注:“开启跑马灯”放在viewDidAppear中,“关闭跑马灯”放在viewWillDisappear中
 */
- (void)marqueeOfSettingWithState:(MarqueeState_H)marqueeState;
  • 注:demo中有详细使用的方法,集成的时候按其方式使用即可,此外,还要注意一下开启/关闭跑马灯方法放置的函数
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    // 开启跑马灯
    [_marquee marqueeOfSettingWithState:MarqueeStart];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    // 关闭跑马灯
    [_marquee marqueeOfSettingWithState:MarqueeShutDown];
}

3. 上下:上下(正向 && 逆向)滚动的跑马灯

a. 简单的集成方式:正常初始化后,传入滚动文字的数据源数组即可

b. 状态自由设置:通过以下方法传入相应的MarqueeState_V枚举值即可

/** 设置跑马灯状态
 *  marqueeState:跑马灯状态(枚举)
 */
- (void)marqueeOfSettingWithState:(MarqueeState_V)marqueeState;

c. 实时回调:通过index属性和scrollWithCallbackBlock方法可以实时获取当前展示文字在数据源数组中的位置

/** 当前显示展示的文字在数据源数组中的索引_只读 */
@property (nonatomic, assign) NSInteger index;

/** 每次滚动回调的Block */
- (void)scrollWithCallbackBlock:(verticalMarqueeBlock)block;

d. 个性化设置:可通过以下属性进行个性化的设置

/** 是否为逆时针滚动(default:NO)
 *  顺时针:底部 ===> 顶部
 *  逆时针:顶部 ===> 底部
 */
@property (nonatomic, assign) BOOL isCounterclockwise;

/** 单次滚动时间(default:0.5f) */
@property (nonatomic, assign) CGFloat scrollDuration;
/** 滚动延迟(default:2.5f) */
@property (nonatomic, assign) CGFloat scrollDelay;

/** 滚动字的颜色(default:blackColor) */
@property (nonatomic, strong) UIColor *verticalTextColor;
/** 滚动的字体(default:14) */
@property (nonatomic, strong) UIFont *verticalTextFont;
/** 显示内容的对齐方式(default:NSTextAlignmentLeft) */
@property (nonatomic, assign) NSTextAlignment verticalTextAlignment;
/** 显示内容的行数(default:2) */
@property (nonatomic, assign) NSInteger verticalNumberOfLines;
  • 在demo中可以查看具体使用方法(使用demo之前请先 pod install

Remind

  • ARC
  • iOS >= 8.0
  • iPhone \ iPad

Hope

  • If you find bug when used,Hope you can Issues me,Thank you or try to download the latest code of this framework to see the BUG has been fixed or not
  • If you find the function is not enough when used,Hope you can Issues me,I very much to add more useful function to this framework ,Thank you !

marquee's People

Contributors

jinht 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

marquee's Issues

有一下问题

已经知道了,但是有两个问题,1.你的这样无法设置字体的颜色和大小吧,我想要使用NSAttributedString的模式进行显示,可是实现不了;2.如果内容特别特别多的时候,跑马灯就不会跑了

设置图片

可以开放.m文件吗?或者可以设置图片吗

崩溃了

运行提示:[JhtHorizontalMarquee initWithFrame:withSingleScrollDuration:]: unrecognized selector sent to instance 0x113940280

不能横向滚动

后台请求回来数据之后,我给horizontalMarquee.text = preMuStr;赋值,就不会滚动了

make 发现个bug

3230ad97-3c79-41f7-ab2e-f7c84c1f203f
我那个PaoMaVC是自定义cell中的UIview我把跑马控件加载到这个view中,并且宽高打印是相等的,但实行跑出来的效果就成图上这样了,请问为什么会这样呢

How to use

看了How to use,还是不懂怎么使用,不用npm install安装吗

release 模式下报警告,是否能优化下

while processing /Users/byrong/Downloads/Marquee-master/JhtMarquee.framework/JhtMarquee(JhtHorizontalMarquee.o):
warning: /Users/jinht/Library/Developer/Xcode/DerivedData/ModuleCache/1CNAI1L4NFVM/UIKit-3QDEVN12FKARC.pcm: No such file or directory
note: Linking a static library that was built with -gmodules, but the module cache was not found. Redistributable static libraries should never be built with module debugging enabled. The debug experience will be degraded due to incomplete debug information.

使用问题

1,用 pod 怎么导入?
2,手动集成需要拷贝哪些文件? 里面.a 结尾的文件是什么?
3,能不能支持swift?

不适配ios7

Object file (/Users/PengJiang/Desktop/项目/天宝/app/app/JhtMarqueeSDK/JhtMarqueeSDK.a(JhtHorizontalMarquee.o)) was built for newer iOS version (8.0) than being linked (7.0)

您好,verticalTextAlignment的问题

当设置verticalTextAlignment 为NSTextAlignmentLeft的时候,文字会挨着边,不是很美观,我猜测,您这个可能是UITextField,可否开放粗来leftView,这样我们可以定制 文字距离 边的大小,

开放源代码问题

你好,今天下载了这个demo,效果不错哈,先给个✨在看!!! 如果代码开源了,会学到更多,望考虑哈~~

能否开源代码

代码貌似都是使用的静态库framework只暴露了都文件夹.h 能否开源.m代码呢?

。。。

    • framework形式的放在github上干嘛呢 谁用谁sb

你好,我用Masonry布局怎么就跑不起来?

          JhtHorizontalMarquee * amountLabel = [[JhtHorizontalMarquee alloc] initWithFrame:CGRectZero withSingleScrollDuration:8.0];
    [amountLabel marqueeOfSettingWithState:MarqueeStart_H];
    [self.contentView addSubview:amountLabel];

[amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-kSpacingDistance);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.height.mas_equalTo(20);
make.left.mas_equalTo(typeLabel.mas_right).offset(5);
}];

速度问题

使用内部计算的duration时,先设置一个较短的text,再设置一个较长的text,速度会加快。。

加入横屏

横屏这个功能在跑马灯这里相当适用,特别是横向跑的.

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.