ios - Get Screen size in Swift as Integer -
for positioning element random in screen within boundarys need resolution/screen size in swift. fount out how cggraphics. unfortunately have calculate bit , need type uint32
, not cgfloat
. cannot use casting way. ideas?
let screensize: cgrect = uiscreen.mainscreen().bounds let screenwidth = screensize.width //what want let screenheight = screensize.height-arc4random_uniform(screensize.height)
if want random x , y positions element can this:
let screensize = uiscreen.mainscreen().bounds let randomxpos = cgfloat(arc4random_uniform(uint32(screensize.width))) let randomypos = cgfloat(arc4random_uniform(uint32(screensize.height)))
Comments
Post a Comment