File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
components/Buttons/examples/supplemental Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,14 @@ - (void)layoutButtonsInRange:(NSRange)range around:(CGFloat)centerX {
122
122
CGFloat labelOffset = (CGRectGetHeight (button.bounds ) - CGRectGetHeight (label.bounds )) / 2 ;
123
123
label.center = CGPointMake (centerX - (CGRectGetWidth (label.bounds ) / 2 ) - kViewOffsetToCenter ,
124
124
heightSum + labelOffset + (CGRectGetHeight (label.bounds ) / 2 ));
125
+
126
+ // Pin the label's frame to pixel boundaries to reduce snapshot flakiness due to inaccuracies in
127
+ // floating point rounding behavior on the GPU when taking snapshots.
128
+ CGRect labelFrame = label.frame ;
129
+ labelFrame.origin .x = floor (labelFrame.origin .x );
130
+ labelFrame.origin .y = floor (labelFrame.origin .y );
131
+ label.frame = labelFrame;
132
+
125
133
heightSum += CGRectGetHeight (button.bounds );
126
134
if (i < self.buttons .count - 1 ) {
127
135
heightSum += button.enabled ? 24 : 36 ;
You can’t perform that action at this time.
0 commit comments