Code Monkey home page Code Monkey logo

Comments (7)

12207480 avatar 12207480 commented on May 21, 2024

我测试了 可以 没问题 我已经更新demo 里面有使用xib的autolayout来创建label

from tyattributedlabel.

smallqiang avatar smallqiang commented on May 21, 2024

用直接赋值label.text=text的方法可以,但是用textContainer的方法就不行了

from tyattributedlabel.

12207480 avatar 12207480 commented on May 21, 2024

你是在cell中使用吗

from tyattributedlabel.

12207480 avatar 12207480 commented on May 21, 2024

可以贴出代码吗

from tyattributedlabel.

smallqiang avatar smallqiang commented on May 21, 2024

对的在cell上使用,
label.numberOfLines = 1;
label.lineBreakMode = kCTLineBreakByTruncatingTail;

NSString *text = @"我是一段很长的文字来的,哈哈哈哈,真的很长,十分长的啊,为什么会这样子的呢?"
label.text = text;

但是如果使用TYTextContainer就不行了
TYTextContainer *textContainer = [[TYTextContainer alloc]init];
textContainer.text = text;

TYTextStorage *textStorage = [[TYTextStorage alloc]init];
textStorage.range = [_result.subject rangeOfString:@"哈哈"];
textStorage.textColor = RGBCOLOR(235, 26, 91);
[textContainer addTextStorage:textStorage];

label.textContainer = textContainer;

因为我需要用到一些其他的样式所以只能用TYTextContainer

from tyattributedlabel.

12207480 avatar 12207480 commented on May 21, 2024

你要在textContainer 设置 numberOfLines lineBreakMode 因为textContainer会覆盖label的

from tyattributedlabel.

smallqiang avatar smallqiang commented on May 21, 2024

好的,可以了,谢谢!以为设置了label就可以了。

from tyattributedlabel.

Related Issues (20)

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.