Swift : Convert (cast) Int or int32 value to CGFloat
Problem :
How to convert (cast) Int or int32 value to CGFloat type in Swift programming language ?
Solution :
Use the CGFloat() function to convert or cast the Int variable. For example :
let x : Int = 100
var cgfx = CGFloat(x)
or
let x32 : Int32 = 3200
var cgfx32 = CGFloat(x32)
See also : Swift : Convert (cast) Int to int32 or Uint32
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.4k Golang : Qt get screen resolution and display on center example
+3.9k Unix/Linux : How to pipe/save output of a command to file?
+50.1k Golang : Check if item is in slice/array
+28k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+20.4k Golang : Convert seconds to minutes and remainder seconds
+5.9k Swift : substringWithRange() function example
+35.2k Golang : Convert(cast) int64 to string
+8.3k Golang : How to generate Code 39 barcode?
+18k Golang : Execute shell command
+3.8k Nginx and PageSpeed build from source CentOS example
+10.3k Golang : Generate DSA private, public key and PEM files example
+12.9k Golang : syscall.Socket example