Code Monkey home page Code Monkey logo

foldlabeldemo's Introduction

FoldLabelDemo

仿微信朋友圈UITableViewCell中文字展开收起功能 最近做社交APP涉及到一个功能,用户发表长文字后显示一定行数,超出一定行数后显示“更多”按钮,同时用户点击后展开文字,再点击收起内容;参考一下朋友圈的交互效果做了个demo,其中关键在于UILabel行数的计算,考虑到不同文字占用字符数不同,并且包含表情等,使用CoreText计算更为合适; 屏幕录制 2019-09-06 上午12.11.19.2019-09-06 00_21_03.gif

核心思路是通过coreText计算UILabel当前显示文字所需要的行数,如果大于最大行数就设置numberOfLines;

foldlabeldemo's People

Contributors

lumianie avatar

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.