iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
hustlzp
V2EX  ›  iDev

如何实现类似微信朋友圈评论的这种排版效果?

  •  
  •   hustlzp · Aug 29, 2015 · 7322 views
    This topic created in 3939 days ago, the information mentioned may be changed or developed.


    类似微信朋友圈评论的这种效果:可点击的人名和普通的文字混排。

    NSAttributedString 倒是可以实现文本混排,但是貌似不太好支持点击。

    各位知道如何实现吗?
    12 replies    2015-08-31 20:35:25 +08:00
    irobbin
        2
    irobbin  
       Aug 29, 2015
    你不知道有个东西叫做 TTTAttributedLabel 吗?
    hustlzp
        3
    hustlzp  
    OP
       Aug 29, 2015
    额,好像找到解决方法了,刚才看了下 @hoogle 的项目:

    https://github.com/singro/v2ex

    在单个话题页使用 TTTAttributedLabel 实现了类似的混排。

    具体在这里:

    https://github.com/hustlzp/v2ex/blob/master/v2ex-iOS/Views/V2TopicReplyCell.m#L406
    hustlzp
        4
    hustlzp  
    OP
       Aug 29, 2015
    @irobbin 刚刚才知道...
    hustlzp
        5
    hustlzp  
    OP
       Aug 29, 2015
    @hoogle

    我刚转行 iOS 开发...你的开源项目很棒, THX !
    HappyHacking
        6
    HappyHacking  
       Aug 29, 2015   ❤️ 1
    我用越狱的 iPhone 加上 Reveal ,看各种第三方的 App 的 UI ,微信的也看过,它的这个文字显示的类名叫做 RichText ,不过我在 GitHub 上没有找到相应的代码,最后用 DTCoreText 实现了
    hustlzp
        7
    hustlzp  
    OP
       Aug 29, 2015
    @HappyHacking THX , DTCoreText 的 star 数也不少啊~
    hoogle
        8
    hoogle  
       Aug 29, 2015   ❤️ 1
    @hustlzp 用 TTTAttributedLabel 可以,也比较方便, 不过它不支持 NSAttachment ,遇到自定义表情什么的就没办法了。
    fhefh
        9
    fhefh  
       Aug 29, 2015
    mark 学习了~
    hustlzp
        10
    hustlzp  
    OP
       Aug 31, 2015
    @hoogle 如果需要支持自定义表情,有什么库可以推荐下吗?或者大概的思路?谢谢了!
    hoogle
        11
    hoogle  
       Aug 31, 2015
    NSAttributedString 里有 link 类型, 加上 1 楼的增加点击的响应
    hustlzp
        12
    hustlzp  
    OP
       Aug 31, 2015
    @hoogle THX
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5315 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 09:10 · PVG 17:10 · LAX 02:10 · JFK 05:10
    ♥ Do have faith in what you're doing.