健康意識の高まり

いろんなメモなど

boundingRectWithSize:options:attributes:context: で計算した値を元に View の size を設定すると文字が切れる問題

問題

boundingRectWithSize:options:attributes:context で計算した値を
そのまま UILabe やら UITextView の size の値に設定すると、文字が切れてしまう。

解決法

ドキュメントに書いてあるまんまなのですが、

This method returns fractional sizes (in the size component of the returned CGRect); to use a returned size to size views, you must use raise its value to the nearest higher integer using the ceil function.

ということで、ceil() してあげましょう、とのこと。