Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
JhtVerticalMarquee支持attributedText
  • Loading branch information
jinht committed Jun 5, 2017
1 parent 855dfbf commit 013a956
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion JhtMarquee.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
children = (
8E3400951ED7D64700ECC223 /* JhtMarqueeSDK.a */,
8E3400961ED7D64700ECC223 /* JhtMarqueeSDK.h */,
8E3400941ED7D64700ECC223 /* JhtHorizontalMarquee.h */,
8E3400971ED7D64700ECC223 /* JhtVerticalMarquee.h */,
8E3400941ED7D64700ECC223 /* JhtHorizontalMarquee.h */,
);
path = JhtMarqueeSDK;
sourceTree = "<group>";
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions JhtMarquee/JhtMarqueeSDK/JhtHorizontalMarquee.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// Copyright © 2016年 JhtMarquee. All rights reserved.
//

/************支持attributedText************/

#import <UIKit/UIKit.h>

/** 跑马灯状态_枚举 */
Expand Down
Binary file modified JhtMarquee/JhtMarqueeSDK/JhtMarqueeSDK.a
Binary file not shown.
4 changes: 2 additions & 2 deletions JhtMarquee/JhtMarqueeSDK/JhtVerticalMarquee.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ typedef void(^verticalMarqueeBlock)(JhtVerticalMarquee *view, NSInteger currentI

#pragma mark - Property
#pragma mark required
/** 滚动文字的 数据源数组 */
@property (nonatomic, strong) NSArray<NSString *> *sourceArray;
/** 滚动文字的 数据源数组(支持attributedText与text混合) */
@property (nonatomic, strong) NSArray *sourceArray;


#pragma mark optional
Expand Down
23 changes: 20 additions & 3 deletions JhtMarquee/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,28 @@ - (void)addVerticalMarquee {
[self.view addSubview:_verticalMarquee];
_verticalMarquee.backgroundColor = [UIColor yellowColor];
_verticalMarquee.verticalTextColor = [UIColor purpleColor];
// NSArray *soureArray = @[@"1. 谁曾从谁的青春里走过,留下了笑靥",
// @"2. 谁曾在谁的花季里停留,温暖了想念",
// @"3. 谁又从谁的雨季里消失,泛滥了眼泪",
// @"4. 人生路,路迢迢,谁道自古英雄多寂寥,若一朝,看透了,一身清风挣多少"
// ];

NSString *str = @"谁曾在谁的花季里停留,温暖了想念";
// 创建NSMutableAttributedString
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:str];
// 设置字体和设置字体的范围
[attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30.0f] range:NSMakeRange(0, 3)];
// 添加文字颜色
[attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(4, 2)];
// 添加文字背景颜色
[attrStr addAttribute:NSBackgroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(7, 2)];
// 添加下划线
[attrStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(11, 5)];
NSArray *soureArray = @[@"1. 谁曾从谁的青春里走过,留下了笑靥",
@"2. 谁曾在谁的花季里停留,温暖了想念",
attrStr,
@"3. 谁又从谁的雨季里消失,泛滥了眼泪",
@"4. 人生路,路迢迢,谁道自古英雄多寂寥,若一朝,看透了,一身清风挣多少"
];
@"4. 人生路,路迢迢,谁道自古英雄多寂寥,若一朝,看透了,一身清风挣多少"];

// _verticalMarquee.isCounterclockwise = YES;
_verticalMarquee.sourceArray = soureArray;
[_verticalMarquee scrollWithCallbackBlock:^(JhtVerticalMarquee *view, NSInteger currentIndex) {
Expand Down
2 changes: 2 additions & 0 deletions JhtMarqueeSDK/JhtHorizontalMarquee.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// Copyright © 2016年 JhtMarquee. All rights reserved.
//

/************支持attributedText************/

#import <UIKit/UIKit.h>

/** 跑马灯状态_枚举 */
Expand Down
Binary file modified JhtMarqueeSDK/JhtMarqueeSDK.a
Binary file not shown.
4 changes: 2 additions & 2 deletions JhtMarqueeSDK/JhtVerticalMarquee.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ typedef void(^verticalMarqueeBlock)(JhtVerticalMarquee *view, NSInteger currentI

#pragma mark - Property
#pragma mark required
/** 滚动文字的 数据源数组 */
@property (nonatomic, strong) NSArray<NSString *> *sourceArray;
/** 滚动文字的 数据源数组(支持attributedText与text混合) */
@property (nonatomic, strong) NSArray *sourceArray;


#pragma mark optional
Expand Down

0 comments on commit 013a956

Please sign in to comment.