How to limit the content in UITextView in ios

前端 未结 7 2284
迷失自我
迷失自我 2021-02-08 11:56

I want to load long text in TextViews of different Views. The text should be divided to pages when it reaches end of the textviews. And the next textview must start with the con

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 12:34

    Option 2 does work in iOS with the proper parameters.

    NSAttributedString *attrStr = ... // your attributed string
    CGFloat width = 300; // whatever your desired width is
    CGRect rect = [attrStr boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
    

    Without the proper values for the options parameter you will get the wrong height.

    got this answer from here

提交回复
热议问题