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.8k Golang : Test a slice of integers for odd and even numbers
+17.4k Unmarshal/Load CSV record into struct in Go
+26.8k Golang : Connect to database (MySQL/MariaDB) server
+31.2k Golang : How to check if a date is within certain range?
+6.3k Golang : Rot13 and Rot5 algorithms example
+5.8k Mac OSX : Find large files by size
+7.3k Golang : Ackermann function example
+12.1k Golang : Read from buffered reader until specific number of bytes
+22.4k Golang : Use regular expression to validate domain name
+10.5k Golang : Find and draw contours with OpenCV example
+16.4k Golang : Aligning strings to right, left and center with fill example