Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift CoreAnimation: zPosition should be within (-FLT_MAX, FLT_MAX) range

I want to keep a view always at the front. In Swift CGFLOAT_MAX and FLT_MAX are replaced with corresponding .greatestFiniteMagnitude. So, I used:

view.layer.zPosition = .greatestFiniteMagnitude

It works fine, but now I get a warning:

CoreAnimation: zPosition should be within (-FLT_MAX, FLT_MAX) range.

Is there a way to get rid of the warning (maybe a better value to use here)?

Thanks.

like image 984
timaktimak Avatar asked Dec 01 '17 09:12

timaktimak


1 Answers

On a 64-bit platform

CGFloat.greatestFiniteMagnitude = Double.greatestFiniteMagnitude = 1.79769313486232e+308
Float.greatestFiniteMagnitude = 3.40282e+38

Apparently the zPosition should be in the (smaller) range of a Float:

view.layer.zPosition = CGFloat(Float.greatestFiniteMagnitude)
like image 74
Martin R Avatar answered Oct 17 '22 12:10

Martin R