diff --git a/JhtMarquee.framework/Headers/JhtHorizontalMarquee.h b/JhtMarquee.framework/Headers/JhtHorizontalMarquee.h index d7d80c2..de3d178 100755 --- a/JhtMarquee.framework/Headers/JhtHorizontalMarquee.h +++ b/JhtMarquee.framework/Headers/JhtHorizontalMarquee.h @@ -9,26 +9,14 @@ // Copyright © 2016年 JhtMarquee. All rights reserved. // -/************支持attributedText************/ - #import +#import "JhtHorizontalMarquee_Define.h" -/** 跑马灯状态_枚举 */ -typedef NS_ENUM(NSUInteger, MarqueeState_H) { - // 开启 - MarqueeStart_H, - // 关闭 - MarqueeShutDown_H, - // 暂停 - MarqueePause_H, - // 取消暂停(继续) - MarqueeContinue_H, -}; - -/** 水平滚动的跑马灯 */ +/** 横向 跑马灯 */ @interface JhtHorizontalMarquee : UILabel + #pragma mark - property -/** 获取_是否处于_暂停状态(只读) */ +/** 获取_是否处于_暂停状态 */ @property (nonatomic, assign, readonly) BOOL isPaused; @@ -41,8 +29,8 @@ typedef NS_ENUM(NSUInteger, MarqueeState_H) { #pragma mark 设置跑马灯状态 /** 设置跑马灯状态 - * marqueeState:跑马灯状态(枚举) - * 注:“开启跑马灯”放在viewDidAppear中,“关闭跑马灯”放在viewWillDisappear中 + * marqueeState:跑马灯状态(MarqueeState_H) + * 注:《开启跑马灯》放在viewDidAppear中,《关闭跑马灯》放在viewWillDisappear中 */ - (void)marqueeOfSettingWithState:(MarqueeState_H)marqueeState; diff --git a/JhtMarquee.framework/Headers/JhtHorizontalMarquee_Define.h b/JhtMarquee.framework/Headers/JhtHorizontalMarquee_Define.h new file mode 100644 index 0000000..81b8e88 --- /dev/null +++ b/JhtMarquee.framework/Headers/JhtHorizontalMarquee_Define.h @@ -0,0 +1,26 @@ +// +// JhtHorizontalMarquee_Define.h +// JhtMarquee +// +// Created by Jht on 2018/5/25. +// Copyright © 2018年 JhtMarquee. All rights reserved. +// + +#ifndef JhtHorizontalMarquee_Define_h +#define JhtHorizontalMarquee_Define_h + + +/** 跑马灯状态_枚举 */ +typedef NS_ENUM(NSUInteger, MarqueeState_H) { + // 开启 + MarqueeStart_H, + // 关闭 + MarqueeShutDown_H, + // 暂停 + MarqueePause_H, + // 取消暂停(继续) + MarqueeContinue_H, +}; + + +#endif /* JhtHorizontalMarquee_Define_h */ diff --git a/JhtMarquee.framework/Headers/JhtVerticalMarquee.h b/JhtMarquee.framework/Headers/JhtVerticalMarquee.h index f4fad65..56dbbd9 100755 --- a/JhtMarquee.framework/Headers/JhtVerticalMarquee.h +++ b/JhtMarquee.framework/Headers/JhtVerticalMarquee.h @@ -10,59 +10,43 @@ // #import +#import "JhtVerticalMarquee_Define.h" -/** 跑马灯状态_枚举 */ -typedef NS_ENUM(NSUInteger, MarqueeState_V) { - // 开启 - MarqueeStart_V, - // 关闭 - MarqueeShutDown_V, - // 暂停 - MarqueePause_V, - // 取消暂停(继续) - MarqueeContinue_V -}; - -/** 上下滚动的跑马灯 */ +/** 纵向 跑马灯 */ @interface JhtVerticalMarquee : UIView + #pragma mark - Property #pragma mark required -/** 滚动文字的 数据源数组(支持attributedText与text混合) */ +/** 跑马灯文字 数据源数组(支持attributedText与text混合) */ @property (nonatomic, strong) NSArray *sourceArray; #pragma mark optional -/** 当前显示展示的文字 在数据源数组中的索引_只读 */ +/** 当前展示内容 索引 */ @property (nonatomic, assign, readonly) NSInteger currentIndex; -/** 是否为逆时针滚动(default:NO) - * 顺时针:底部 ===> 顶部 - * 逆时针:顶部 ===> 底部 - */ -@property (nonatomic, assign) BOOL isCounterclockwise; - -/** 单次滚动时间 +/** 单次滚动 时间 * default:0.5f */ @property (nonatomic, assign) CGFloat scrollDuration; -/** 滚动延迟 - * default:2.5f +/** 滚动延迟 时间 + * default:3.0f */ @property (nonatomic, assign) CGFloat scrollDelay; -/** 滚动文字的颜色 +/** 文字 颜色 * default:[UIColor blackColor] */ @property (nonatomic, strong) UIColor *verticalTextColor; -/** 滚动文字的字体 +/** 文字 字体 * default:[UIFont systemFontOfSize:14] */ @property (nonatomic, strong) UIFont *verticalTextFont; -/** 显示文字的对齐方式 +/** 文字 对齐方式 * default:NSTextAlignmentLeft */ @property (nonatomic, assign) NSTextAlignment verticalTextAlignment; -/** 显示文字的行数 +/** 文字 行数 * default:2(注意一下self.frame的设置) */ @property (nonatomic, assign) NSInteger verticalNumberOfLines; @@ -75,7 +59,7 @@ typedef NS_ENUM(NSUInteger, MarqueeState_V) { */ - (void)marqueeOfSettingWithState:(MarqueeState_V)marqueeState; -/** 每次滚动回调的Block */ +/** 滚动 回调 */ typedef void(^verticalMarqueeBlock)(JhtVerticalMarquee *view, NSInteger currentIndex); - (void)scrollWithCallbackBlock:(verticalMarqueeBlock)block; diff --git a/JhtMarquee.framework/Headers/JhtVerticalMarquee_Define.h b/JhtMarquee.framework/Headers/JhtVerticalMarquee_Define.h new file mode 100644 index 0000000..5e34aa2 --- /dev/null +++ b/JhtMarquee.framework/Headers/JhtVerticalMarquee_Define.h @@ -0,0 +1,26 @@ +// +// JhtVerticalMarquee_Define.h +// JhtMarquee +// +// Created by Jht on 2018/5/25. +// Copyright © 2018年 JhtMarquee. All rights reserved. +// + +#ifndef JhtVerticalMarquee_Define_h +#define JhtVerticalMarquee_Define_h + + +/** 跑马灯状态_枚举 */ +typedef NS_ENUM(NSUInteger, MarqueeState_V) { + // 开启 + MarqueeStart_V, + // 关闭 + MarqueeShutDown_V, + // 暂停 + MarqueePause_V, + // 取消暂停(继续) + MarqueeContinue_V +}; + + +#endif /* JhtVerticalMarquee_Define_h */ diff --git a/JhtMarquee.framework/Info.plist b/JhtMarquee.framework/Info.plist index 4d8d642..1db3ae4 100644 Binary files a/JhtMarquee.framework/Info.plist and b/JhtMarquee.framework/Info.plist differ diff --git a/JhtMarquee.framework/JhtMarquee b/JhtMarquee.framework/JhtMarquee index 6e1e784..c1ef937 100644 Binary files a/JhtMarquee.framework/JhtMarquee and b/JhtMarquee.framework/JhtMarquee differ diff --git a/JhtMarquee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/JhtMarquee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/JhtMarquee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/JhtMarquee.xcodeproj/project.xcworkspace/xcuserdata/Jht.xcuserdatad/UserInterfaceState.xcuserstate b/JhtMarquee.xcodeproj/project.xcworkspace/xcuserdata/Jht.xcuserdatad/UserInterfaceState.xcuserstate index 2994949..b61ca76 100755 Binary files a/JhtMarquee.xcodeproj/project.xcworkspace/xcuserdata/Jht.xcuserdatad/UserInterfaceState.xcuserstate and b/JhtMarquee.xcodeproj/project.xcworkspace/xcuserdata/Jht.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/JhtMarquee/ViewController.m b/JhtMarquee/ViewController.m index 50ce121..66f9b47 100755 --- a/JhtMarquee/ViewController.m +++ b/JhtMarquee/ViewController.m @@ -18,12 +18,12 @@ #define FrameW [UIScreen mainScreen].bounds.size.width @interface ViewController () { - // 水平滚动的跑马灯 + // 横向 跑马灯 JhtHorizontalMarquee *_horizontalMarquee; - // 上下滚动的跑马灯 + // 纵向 跑马灯 JhtVerticalMarquee *_verticalMarquee; - // 是否暂停了上下滚动的跑马灯 + // 是否暂停了纵向 跑马灯 BOOL _isPauseV; } @@ -34,7 +34,7 @@ @implementation ViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - // 如果暂停了,使用继续方式开启 + if (_isPauseV) { [_verticalMarquee marqueeOfSettingWithState:MarqueeContinue_V]; } @@ -55,102 +55,124 @@ - (void)viewDidLoad { self.automaticallyAdjustsScrollViewInsets = NO; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 self.navigationController.interactivePopGestureRecognizer.enabled = YES; self.navigationController.interactivePopGestureRecognizer.delegate = self; - } - if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) { + +#else self.navigationController.interactivePopGestureRecognizer.delegate = self; - } +#endif - // 创建UI界面 [self createUI]; } #pragma mark - UI -/** 创建UI界面 */ +/** createUI */ - (void)createUI { self.view.backgroundColor = [UIColor whiteColor]; self.title = @"JhtMarqueeDemo"; - // 添加水平滚动的跑马灯 + // 添加 横向 跑马灯 [self addHorizontalMarquee]; - // 添加上下滚动的跑马灯 + // 添加 纵向 跑马灯 [self addVerticalMarquee]; } -#pragma mark 水平滚动的跑马灯 -/** 添加水平滚动的跑马灯 */ +#pragma mark 横向 跑马灯 +/** 添加 横向 跑马灯 */ - (void)addHorizontalMarquee { - _horizontalMarquee = [[JhtHorizontalMarquee alloc] initWithFrame:CGRectMake(0, 64 + 20, FrameW, 40) withSingleScrollDuration:10.0]; - _horizontalMarquee.text = @"这是一个跑马灯View,测试一下好不好用,哈哈哈,😁👌😀 😁👌😀 😁👌😀 😁👌😀 哈哈哈哈! "; - [self.view addSubview:_horizontalMarquee]; - - // 给跑马灯添加点击手势 - UITapGestureRecognizer *htap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(horizontalMarqueeTapGes:)]; - [_horizontalMarquee addGestureRecognizer:htap]; -} - -- (void)horizontalMarqueeTapGes:(UITapGestureRecognizer *)ges { - NSLog(@"点击__水平__滚动的跑马灯啦!!!"); - [_verticalMarquee marqueeOfSettingWithState:MarqueePause_V]; - _isPauseV = YES; - - [self.navigationController pushViewController:[[testVC alloc] init] animated:YES]; + self.horizontalMarquee.text = @" 这是一个跑马灯View,测试一下好不好用,哈哈哈,😁👌😀 😁👌😀 😁👌😀 😁👌😀 哈哈哈哈! "; + [self.view addSubview:self.horizontalMarquee]; } -#pragma mark 上下滚动的跑马灯 -/** 添加上下滚动的跑马灯 */ +#pragma mark 纵向 跑马灯 +/** 添加纵向 跑马灯 */ - (void)addVerticalMarquee { - _verticalMarquee = [[JhtVerticalMarquee alloc] initWithFrame:CGRectMake(10, 200, FrameW - 20, 45)]; - [self.view addSubview:_verticalMarquee]; - _verticalMarquee.backgroundColor = [UIColor yellowColor]; - _verticalMarquee.verticalTextColor = [UIColor purpleColor]; -// NSArray *soureArray = @[@"1. 谁曾从谁的青春里走过,留下了笑靥", -// @"2. 谁曾在谁的花季里停留,温暖了想念", -// @"3. 谁又从谁的雨季里消失,泛滥了眼泪", -// @"4. 人生路,路迢迢,谁道自古英雄多寂寥,若一朝,看透了,一身清风挣多少" -// ]; + [self.view addSubview:self.verticalMarquee]; + + [self.verticalMarquee scrollWithCallbackBlock:^(JhtVerticalMarquee *view, NSInteger currentIndex) { + NSLog(@"滚动到第 %ld 条数据", (long)currentIndex); + }]; + /* + 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. 谁曾从谁的青春里走过,留下了笑靥", attrStr, @"3. 谁又从谁的雨季里消失,泛滥了眼泪", @"4. 人生路,路迢迢,谁道自古英雄多寂寥,若一朝,看透了,一身清风挣多少"]; -// _verticalMarquee.isCounterclockwise = YES; - _verticalMarquee.sourceArray = soureArray; - [_verticalMarquee scrollWithCallbackBlock:^(JhtVerticalMarquee *view, NSInteger currentIndex) { - NSLog(@"滚动到第 %ld 条数据", (long)currentIndex); - }]; + self.verticalMarquee.sourceArray = soureArray; // 开始滚动 - [_verticalMarquee marqueeOfSettingWithState:MarqueeStart_V]; + [self.verticalMarquee marqueeOfSettingWithState:MarqueeStart_V]; +} + + + +#pragma mark - Get +/** 横向 跑马灯 */ +- (JhtHorizontalMarquee *)horizontalMarquee { + if (!_horizontalMarquee) { + _horizontalMarquee = [[JhtHorizontalMarquee alloc] initWithFrame:CGRectMake(0, 66, FrameW, 40) withSingleScrollDuration:10.0]; + + // 添加点击手势 + UITapGestureRecognizer *htap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(horizontalMarqueeTapGes:)]; + [_horizontalMarquee addGestureRecognizer:htap]; + } + + return _horizontalMarquee; +} + +/** 纵向 跑马灯 */ +- (JhtVerticalMarquee *)verticalMarquee { + if (!_verticalMarquee) { + _verticalMarquee = [[JhtVerticalMarquee alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.horizontalMarquee.frame) + 40, FrameW - 20, 45)]; + + _verticalMarquee.backgroundColor = [UIColor yellowColor]; + _verticalMarquee.verticalTextColor = [UIColor purpleColor]; + + // 添加点击手势 + UITapGestureRecognizer *vtap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(verticalMarqueeTapGes:)]; + [_verticalMarquee addGestureRecognizer:vtap]; + } - // 给跑马灯添加点击手势 - UITapGestureRecognizer *vtap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(verticalMarqueeTapGes:)]; - [_verticalMarquee addGestureRecognizer:vtap]; + return _verticalMarquee; } + +#pragma mark Get Method +/** 点击 水平滚动跑马灯 触发方法 */ +- (void)horizontalMarqueeTapGes:(UITapGestureRecognizer *)ges { + NSLog(@"点击__水平__滚动的跑马灯啦!!!"); + [self.verticalMarquee marqueeOfSettingWithState:MarqueePause_V]; + _isPauseV = YES; + + [self.navigationController pushViewController:[[testVC alloc] init] animated:YES]; +} + +/** 点击 纵向滚动跑马灯 触发方法 */ - (void)verticalMarqueeTapGes:(UITapGestureRecognizer *)ges { - NSLog(@"点击__纵向__滚动的跑马灯_第 %ld 条数据啦!!!", (long)_verticalMarquee.currentIndex); - [_verticalMarquee marqueeOfSettingWithState:MarqueePause_V]; + NSLog(@"点击__纵向__滚动的跑马灯_第 %ld 条数据啦!!!", (long)self.verticalMarquee.currentIndex); + [self.verticalMarquee marqueeOfSettingWithState:MarqueePause_V]; _isPauseV = YES; [self.navigationController pushViewController:[[testVC alloc] init] animated:YES]; @@ -158,6 +180,7 @@ - (void)verticalMarqueeTapGes:(UITapGestureRecognizer *)ges { + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.