NSParagraphStyle+QMUI.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Tencent is pleased to support the open source community by making QMUI_iOS available.
  3. * Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
  4. * 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
  5. * http://opensource.org/licenses/MIT
  6. * 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.
  7. */
  8. //
  9. // NSParagraphStyle+QMUI.h
  10. // qmui
  11. //
  12. // Created by QMUI Team on 16/8/9.
  13. //
  14. #import <Foundation/Foundation.h>
  15. #import <UIKit/UIKit.h>
  16. @interface NSParagraphStyle (QMUI)
  17. /**
  18. * 快速创建一个NSMutableParagraphStyle,等同于`qmui_paragraphStyleWithLineHeight:lineBreakMode:NSLineBreakByWordWrapping textAlignment:NSTextAlignmentLeft`。
  19. * 注意 NSParagraphStyle.lineBreakMode 默认值为 NSLineBreakByWordWrapping,而 UILabel.lineBreakMode 默认值为 NSLineBreakByTruncatingTail。如果 UILabel.attributedText 里显式设置了 NSParagraphStyle,则 UILabel.lineBreakMode 返回的值会由 attributedText 里的 NSParagraphStyle.lineBreakMode 决定。
  20. * @param lineHeight 行高
  21. * @return 一个NSMutableParagraphStyle对象
  22. */
  23. + (instancetype)qmui_paragraphStyleWithLineHeight:(CGFloat)lineHeight;
  24. /**
  25. * 快速创建一个NSMutableParagraphStyle,等同于`qmui_paragraphStyleWithLineHeight:lineBreakMode:textAlignment:NSTextAlignmentLeft`
  26. * @param lineHeight 行高
  27. * @param lineBreakMode 换行模式
  28. * @return 一个NSMutableParagraphStyle对象
  29. */
  30. + (instancetype)qmui_paragraphStyleWithLineHeight:(CGFloat)lineHeight lineBreakMode:(NSLineBreakMode)lineBreakMode;
  31. /**
  32. * 快速创建一个NSMutableParagraphStyle
  33. * @param lineHeight 行高
  34. * @param lineBreakMode 换行模式
  35. * @param textAlignment 文本对齐方式
  36. * @return 一个NSMutableParagraphStyle对象
  37. */
  38. + (instancetype)qmui_paragraphStyleWithLineHeight:(CGFloat)lineHeight lineBreakMode:(NSLineBreakMode)lineBreakMode textAlignment:(NSTextAlignment)textAlignment;
  39. @end