Git Product home page Git Product logo

dflabelsizefit's Introduction

DFLabelSizeFit

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

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

dflabelsizefit's People

Contributors

ihoudf avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

carabina asdlei99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.