Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>LMJScrollText.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
22 changes: 22 additions & 0 deletions LMJScrollText/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ @interface ViewController ()
LMJScrollTextView * _scrollTextView1_2;

LMJScrollTextView * _scrollTextView2;
LMJScrollTextView * _scrollTextView21;
LMJScrollTextView * _scrollTextView3;
LMJScrollTextView * _scrollTextView31;
LMJScrollTextView * _scrollTextView4;
LMJScrollTextView * _scrollTextView5;
LMJScrollTextView * _scrollTextView6;
Expand Down Expand Up @@ -68,6 +70,7 @@ - (void)viewDidLoad {
[_scrollTextView2 startScrollWithText:@"<<<向左连续滚动字符串|向左连续滚动字符串|向左连续滚动字符串" textColor:[UIColor blackColor] font:[UIFont systemFontOfSize:16]];



//向右,连续滚动
[self addLabelWithFrame:CGRectMake(10, 185, 400, 20) text:@"向右,连续滚动(right,continuous)"];

Expand Down Expand Up @@ -129,7 +132,24 @@ - (void)viewDidLoad {



//向左,连续滚动,超过一半,就开始新的
[self addLabelWithFrame:CGRectMake(10, 475, 400, 20) text:@"向左,连续滚动(left,continuousHalf)"];

_scrollTextView21 = [[LMJScrollTextView alloc] initWithFrame:CGRectMake(10, 495, 300, 30) textScrollModel:LMJTextScrollContinuousHalf direction:LMJTextScrollMoveLeft];
_scrollTextView21.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_scrollTextView21];

[_scrollTextView21 startScrollWithText:@"<<<向左连续滚动字符串|向左连续滚动字符串|向左连续滚动字符串" textColor:[UIColor blackColor] font:[UIFont systemFontOfSize:16]];


//向右,连续滚动 滚到一半重新出现
[self addLabelWithFrame:CGRectMake(10, 525, 400, 20) text:@"向右,连续滚动(right,continuousHalf)"];

_scrollTextView31 = [[LMJScrollTextView alloc] initWithFrame:CGRectMake(10, 545, 300, 30) textScrollModel:LMJTextScrollContinuousHalf direction:LMJTextScrollMoveRight];
_scrollTextView31.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_scrollTextView31];

[_scrollTextView31 startScrollWithText:@"向右连续滚动字符串>>>" textColor:[UIColor blackColor] font:[UIFont systemFontOfSize:16]];



Expand Down Expand Up @@ -162,6 +182,8 @@ -(void)changeSpeed{
[_scrollTextView5 setMoveSpeed:speed];
[_scrollTextView6 setMoveSpeed:speed];
[_scrollTextView7 setMoveSpeed:speed];
[_scrollTextView21 setMoveSpeed:speed];
[_scrollTextView31 setMoveSpeed:speed];
}
}

Expand Down
1 change: 1 addition & 0 deletions LMJScrollTextView/LMJScrollTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
typedef enum {
LMJTextScrollContinuous, // 从控件内开始连续滚动
LMJTextScrollContinuousHalf, // 自定义 连续滚动过半、就开始下一个
LMJTextScrollIntermittent, // 从控件内开始间断滚动
LMJTextScrollFromOutside, // 从控件外开始滚动
LMJTextScrollWandering // 在控件中往返滚动(不受设置方向影响)
Expand Down
38 changes: 38 additions & 0 deletions LMJScrollTextView/LMJScrollTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ -(void)startScroll{

}break;

case LMJTextScrollContinuousHalf:
{
if (_currentMoveDirection == LMJTextScrollMoveLeft) {
[self creatLabel1WithFrame1:CGRectMake(0, 0, _textWidth, self.frame.size.height) andLabel2WithFrame2:CGRectMake(self.frame.size.width/2 + _textWidth, 0, _textWidth, self.frame.size.height)];
}else{
[self creatLabel1WithFrame1:CGRectMake(self.frame.size.width -_textWidth, 0, _textWidth, self.frame.size.height) andLabel2WithFrame2:CGRectMake(self.frame.size.width -_textWidth -_textWidth - self.frame.size.width/2, 0, _textWidth, self.frame.size.height)];
}

}break;

case LMJTextScrollIntermittent:
{
if (_currentMoveDirection == LMJTextScrollMoveLeft) {
Expand Down Expand Up @@ -182,6 +192,11 @@ - (void)contentMove {
[self moveContinuous];
}
break;
case LMJTextScrollContinuousHalf:
{
[self moveContinuousHalf];
}
break;
case LMJTextScrollIntermittent:
{
[self moveIntermittent];
Expand Down Expand Up @@ -223,6 +238,29 @@ -(void)moveContinuous{
}
}
}

//连续滚动中间过半就出现
-(void)moveContinuousHalf{
if (_currentMoveDirection == LMJTextScrollMoveLeft) {
_contentLabel1.frame = CGRectMake(_contentLabel1.frame.origin.x -1, 0, _textWidth, self.frame.size.height);
_contentLabel2.frame = CGRectMake(_contentLabel2.frame.origin.x -1, 0, _textWidth, self.frame.size.height);
if (_contentLabel1.frame.origin.x < -_textWidth) {
_contentLabel1.frame = CGRectMake(_contentLabel2.frame.origin.x + _textWidth + self.frame.size.width/2, 0, _textWidth, self.frame.size.height);
}
if (_contentLabel2.frame.origin.x < -_textWidth) {
_contentLabel2.frame = CGRectMake(_contentLabel1.frame.origin.x + _textWidth + self.frame.size.width/2, 0, _textWidth, self.frame.size.height);
}
}else{
_contentLabel1.frame = CGRectMake(_contentLabel1.frame.origin.x +1, 0, _textWidth, self.frame.size.height);
_contentLabel2.frame = CGRectMake(_contentLabel2.frame.origin.x +1, 0, _textWidth, self.frame.size.height);
if (_contentLabel1.frame.origin.x > self.frame.size.width) {
_contentLabel1.frame = CGRectMake(_contentLabel2.frame.origin.x - _textWidth - self.frame.size.width/2, 0, _textWidth, self.frame.size.height);
}
if (_contentLabel2.frame.origin.x > self.frame.size.width) {
_contentLabel2.frame = CGRectMake(_contentLabel1.frame.origin.x - _textWidth- self.frame.size.width/2, 0, _textWidth, self.frame.size.height);
}
}
}
//间断滚动
-(void)moveIntermittent{
if (_currentMoveDirection == LMJTextScrollMoveLeft) {
Expand Down