cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/QMUIMarqueeLabel.h

94 lines
4.7 KiB
C
Raw Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// QMUIMarqueeLabel.h
// qmui
//
// Created by QMUI Team on 2017/5/31.
//
#import <UIKit/UIKit.h>
/**
* label label
* @warning lineBreakMode NSLineBreakByClippingUILabel NSLineBreakByTruncatingTail
* @warning textAlignment NSTextAlignmentJustified NSTextAlignmentNatural
* @warning numberOfLines 1
*/
@interface QMUIMarqueeLabel : UILabel
/// 控制滚动的速度1 表示一帧滚动 1pt10 表示一帧滚动 10pt默认为 .5,与系统一致。
@property(nonatomic, assign) IBInspectable CGFloat speed;
/// 当文字第一次显示在界面上,以及重复滚动到开头时都要停顿一下,这个属性控制停顿的时长,默认为 2.5(也是与系统一致),单位为秒。
@property(nonatomic, assign) IBInspectable NSTimeInterval pauseDurationWhenMoveToEdge;
/// 用于控制首尾连接的文字之间的间距,默认为 40pt。
@property(nonatomic, assign) IBInspectable CGFloat spacingBetweenHeadToTail;
// 用于控制左和右边两端的渐变区域的百分比,默认为 0.2,则是 20% 宽。
@property(nonatomic, assign) IBInspectable CGFloat fadeWidthPercent;
/**
* label frame UIWindow YES
* @warning label.superview frame label frame
*/
@property(nonatomic, assign) IBInspectable BOOL automaticallyValidateVisibleFrame;
/// 在文字滚动到左右边缘时,是否要显示一个阴影渐变遮罩,默认为 YES。
@property(nonatomic, assign) IBInspectable BOOL shouldFadeAtEdge;
/// YES 表示文字会在打开 shouldFadeAtEdge 的情况下从左边的渐隐区域之后显示NO 表示不管有没有打开 shouldFadeAtEdge都会从 label 的边缘开始显示。默认为 NO。
/// @note 如果文字宽度本身就没超过 label 宽度(也即无需滚动),此时必定不会显示渐隐,则这个属性不会影响文字的显示位置。
@property(nonatomic, assign) IBInspectable BOOL textStartAfterFade;
@end
/// 如果在可复用的 UIView 里使用(例如 UITableViewCell、UICollectionViewCell由于 UIView 可能重复被使用,因此需要在某些显示/隐藏的时机去手动开启/关闭 label 的动画。如果在普通的 UIView 里使用则无需关注这一部分的代码。
@interface QMUIMarqueeLabel (ReusableView)
/**
* label
* @return
*/
- (BOOL)requestToStartAnimation;
/**
* label
* @return
*/
- (BOOL)requestToStopAnimation;
@end
@interface UILabel (QMUI_Marquee)
/**
/使 @c QMUIMarqueeLabel
[label qmui_startNativeMarquee];
[label qmui_stopNativeMarquee]; // 当你需要停止动画时,调用这个方法(如果业务只关心什么时候开启,不关心什么时候结束,则从头到尾都可以不用调用这个方法)
@note numberOfLines 1clipsToBounds YES reuse view 使 UITableViewCell/UICollectionViewCell will display startdid end display stop
*/
- (void)qmui_startNativeMarquee;
/**
@c qmui_startNativeMarquee
*/
- (void)qmui_stopNativeMarquee;
/**
NO
*/
@property(nonatomic, assign, readonly) BOOL qmui_nativeMarqueeRunning;
@end