Things take time

[SWIFT] String <-> Float(CGFloat) 변환, Int -> Cgflaot 본문

iOS (기능)

[SWIFT] String <-> Float(CGFloat) 변환, Int -> Cgflaot

겸손할 겸 2018. 5. 17. 16:55

1) Float -> String

                let stringValue = String(describing: floatValue)

 

2) String -> CGFloat

let floatValue = CGFloat((stringValue as NSString).floatValue)

 

3) Int -> CGFloat

let floatValue = CGFloat(intValue)

 

float이 필요하다면 .floatValue로만!