我们在浏览网页或者在使用一些娱乐新闻类的App的时候,会经常看到标题如果过长的话,会有一个滚动的效果,那么这种效果是怎样实现的呢?我在这里为大家介绍两种方法:
- 利用时间器,在一定的时间间隔内,不断地向后截取,并且每次截取的长度是相同的。
1.1首先定义几个全局变量
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)NSString *titleString;
@property (nonatomic,assign)int fromLocation;//字符串截取的开始位置
1.2为文字字符串赋值
_titleString=@