Latest 1.1.2
Homepage https://github.com/ihoudf/DFLabelSizeFit
License MIT
Platforms ios 6.0, requires ARC
Authors

DFLabelSizeFit
DFLabelSizeFit
DFLabelSizeFit
DFLabelSizeFit
DFLabelSizeFit
DFLabelSizeFit

one line of code to fit label size.(一行代码自适应label size)

DFLabelSizeFit

system Requirements

requires iOS 6.0+.

Installation

CocoaPods
1.Add pod 'DFLabelSizeFit' to your Podfile.
2.Run pod install or pod update.
3.import "DFLabelSizeFit.h"
Manually
1.Download all the files in the DFLabelSizeFit subdirectory.
2.Add the DFLabelSizeFit group to your Xcode project.
3.import "DFLabelSizeFit.h

Document

  • use these methods you should set label’s frame at first.

1.single line text. the label height you get is the fontsize.According textAlignment set label’s frame.

- (UILabel *)df_labelSizeFit;

2.single line text.only fit width. the label height you get is the frame.size.height you set.

- (UILabel *)df_labelSizeFitKeepOldHeight;

3. Multiline text in one paragraph.
@param lineSpacing lineSpacing
@param singleLineKeepWidth when single line,keep width you set or get the actual label width.

- (UILabel *)df_labelSizeFitWithLineSpacing:(CGFloat)lineSpacing
                        singleLineKeepWidth:(BOOL)singleLineKeepWidth;

4. muti paragraph.

@param lineSpacing lineSpacing
@param paragraphSpacingBefore paragraphSpacingBefore
@param alignment alignment
@param isFirstLineHeadIndent isFirstLineHeadIndent

- (UILabel *)df_labelSizeFitWithLineSpacing:(CGFloat)lineSpacing
                     paragraphSpacingBefore:(CGFloat)paragraphSpacingBefore
                                  alignment:(NSTextAlignment)alignment
                      isFirstLineHeadIndent:(BOOL)isFirstLineHeadIndent;

License

provided under the MIT license. See LICENSE file for details.

中文介绍

系统要求

最低支持 iOS 6.0

安装

CocoaPods
1.在 Podfile 中添加 pod 'DFLabelSizeFit'。
2.执行 pod install 或 pod update。
3.导入 "DFLabelSizeFit.h"。
手动安装
1.下载 DFLabelSizeFit 文件夹内的所有内容。
2.将 DFLabelSizeFit文件夹添加(拖放)到你的工程。
3.import "DFLabelSizeFit.h"

文档

  • 使用这些方法前你需要先设置label的frame

1.单行。返回label高度是font值的pointSize。并根据textAlignment设置label的位置。

- (UILabel *)df_labelSizeFit;

2.单行。自适应宽。返回高为你设置的frame的height

- (UILabel *)df_labelSizeFitKeepOldHeight;

3. 多行
@param lineSpacing 行距
@param keepWidth 文字单行时是保持设置的frame的width还是返回实际的label的width

- (UILabel *)df_labelSizeFitWithLineSpacing:(CGFloat)lineSpacing
                        singleLineKeepWidth:(BOOL)singleLineKeepWidth;

4. 多段落设置富文本
@param lineSpacing 行距
@param paragraphSpacingBefore 段落之间的间距
@param alignment 对齐方式
@param isFirstLineHeadIndent 首行是否缩进两字符

- (UILabel *)df_labelSizeFitWithLineSpacing:(CGFloat)lineSpacing
                     paragraphSpacingBefore:(CGFloat)paragraphSpacingBefore
                                  alignment:(NSTextAlignment)alignment
                      isFirstLineHeadIndent:(BOOL)isFirstLineHeadIndent;

许可证

使用 MIT 许可证,详情见LICENSE 文件。

THANKS!

qq交流群:479873475

合作qq:188816190

Latest podspec

{
    "name": "DFLabelSizeFit",
    "version": "1.1.2",
    "summary": "one line of code to fit label size.",
    "homepage": "https://github.com/ihoudf/DFLabelSizeFit",
    "license": "MIT",
    "authors": {
        "ihoudf": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/ihoudf/DFLabelSizeFit.git",
        "tag": "1.1.2"
    },
    "source_files": [
        "DFLabelSizeFit",
        "DFLabelSizeFit/**/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This