LoginSignup
7
9

More than 3 years have passed since last update.

CGFloatの小数点第一位までを文字列として取り出す

Last updated at Posted at 2014-09-18

あるCGFloatがあって、その小数点第一位までを文字列として取り出したかった。結果としてこうなった。

let someCGFloat: CGFloat = 0.25
var text = String(format: "%.01f", someCGFloat)
// 0.2
7
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9