Is there a constant for the maximum CGFloat value?

前端 未结 8 764
滥情空心
滥情空心 2021-02-02 05:09

I need to create a CGSize to compute text height of an arbitrary text with arbitrary length. UIKit has this nice method -sizeWithFont:constrainedToSize: and my text is only cons

相关标签:
8条回答
  • 2021-02-02 06:14

    For those using Swift 2, you should use:

    CGFloat.max
    

    For those using Swift 3, you should use:

    CGFloat.greatestFiniteMagnitude
    

    Note that CGFloat.max was removed when Swift 3 came out, as reflected in the documentation.

    0 讨论(0)
  • 2021-02-02 06:15

    I was looking for a Swift version of minimum CGFloat value and landed here, if you too ;) then here is the answer:

    CGFloat.leastNormalMagnitude
    
    0 讨论(0)
提交回复
热议问题