ios - CALayer zPosition ordering with extremely large values -
I have attended an issue where the core animation appears to be zPosition
for my values Ignoring the values become larger.
example
It can be easily replicated
CGFloat largeZPosition = 1000000000; CALayer * topLayer = ... CALayer * bottomLayer = ... belowLeather.frame = CGFFetset (toplinerframe, 50, 50); TopLayer.zPosition = Big ZPosition + 1; Downlayer ZPosition = Large ZPosition; // Sort arithmetic array in wrong order RootLayer.sublayers = @ [header, bottom letter];
With small values for z-position, this function, as expected, even if the sub-column array is not sorted correctly, the bottom side is displayed on the top side Such as:
However, the examples shown above , The result is as follows:
Obviously this is not right.
Question
I'm unable to classify manual inventory for my needs, so I'm relying on zPosition
to perform as expected So my question is: How do I work around this problem? Thank you.
That's because Quartzcore has been composed of zPosition
to float
, therefore it loses the accuracy when CGFloat
is double
. IEEE single-precision floating-point numbers use 24 bits meaning more accurate, so more than 2 ^ 24 integral numbers can not be properly represented. For example,
float biggeonation = 1000000000; Float bigZPositionPlus1 = 1000000001; NSLog (@ "% F% F% D", Largegeonation, LargeGroup Plus 1, Biggerency == LargeJustnessPlus1);
Output
1000000000.000000 1000000000.000000 1
The next accurate representational integer is 1000000064.
Note that CALayer.zPosition
is defined as CGFloat
and it is capable of having an integral value greater than 2 ^ 24 , As long as the underlying CGFloat
is able to do this
layer.zPosition = 1000000001; NSLog (@ "% F", Layer .ZPosition); 64-bit OS X
Where CGFloat
is double
, output
1000000001.000000
Therefore, on CALayer
public purpose - at C class level, it has not been lost. Wherever there is a conversion for single-precision float
anywhere in Quartzcor.
I suggest using integral numbers (including the result of extra) which is less than 2 ^ 24. Given that there is a floating-point type in zPosition
, you can use small partial values instead of large integral values.
Comments
Post a Comment