You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.9 KiB

/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2020 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.
*/
//
// UILabel+QMUI.h
// qmui
//
// Created by QMUI Team on 15/7/20.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
extern const CGFloat QMUILineHeightIdentity;
@interface UILabel (QMUI)
- (instancetype)qmui_initWithFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor;
/**
* @brief label NSAttributeName setText 使 attributedText
*
* @note 使 setText/attributedText
* @note NSKernAttributeName kern
*
* @note setText: setAttributedText:
*
* label
* 1. textColor, font
* 2. qmui_textAttributes
* 3. NSAttributedString
* 使12
* 21 setText12使12
*
*/
@property(nullable, nonatomic, copy) NSDictionary<NSAttributedStringKey, id> *qmui_textAttributes;
/**
* Setter
* @note qmui_textAttributes attributedText qmui_textAttributes attributedText
* @note "abc" attributedText {0, 1} range 10 setQmui_lineHeight: 20 {0, 1} 10 {1, 2} 20
* @note "abc" setQmui_lineHeight: 10 attributedText/qmui_textAttributes 20 20
* @note 'QMUILineHeightIdentity' UILabel
* @note setText: setAttributedText:
*
* -----------------------------------
*
* Getter
* @note setQmui_lineHeight
* @note NSParagraphStyleAttributeName range paraStyle.maximumLineHeight
* @note setText font.lineHeight
* @warning 0
*
*/
@property(nonatomic, assign) CGFloat qmui_lineHeight;
/**
* UILabel的样式属性设置到当前UILabel上
*
* fonttextColorbackgroundColor
* @param label UILabel上复制样式
*/
- (void)qmui_setTheSameAppearanceAsLabel:(UILabel *)label;
/**
* UILabel的样式label的text设置为一个测试字符sizeToFitlabel的高度适应字体
* @warning setText:text之前调用
*/
- (void)qmui_calculateHeightAfterSetAppearance;
/**
* UILabel在显示中文字符时sublayerslayer超出了label.bounds的范围label必定需要做像素合成
* @see http://stackoverflow.com/questions/34895641/uilabel-is-marked-as-red-when-color-blended-layers-is-selected
*/
- (void)qmui_avoidBlendedLayersIfShowingChineseWithBackgroundColor:(UIColor *)color;
@end
NS_ASSUME_NONNULL_END