mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Layout round instead of ceiling (#3833)
* Layout round instead of cailing Add helper method to layout module to convert to/from dips to px and measure the native view whiteSpace affects layout added for iOS Fix bug in switch onMeasure implementation Fix bug in cssValueToDevicePixels iOS implementation ActionBar for iOS is measured with AT_MOST modifier * Fix switch measure routine
This commit is contained in:
@ -26,6 +26,7 @@ class SwitchChangeHandlerImpl extends NSObject {
|
||||
};
|
||||
}
|
||||
|
||||
const zeroSize = { width: 0, height: 0 };
|
||||
export class Switch extends SwitchBase {
|
||||
private _ios: UISwitch;
|
||||
private _handler: NSObject;
|
||||
@ -52,12 +53,12 @@ export class Switch extends SwitchBase {
|
||||
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
// It can't be anything different from 51x31
|
||||
let nativeSize = this._nativeView.sizeThatFits(CGSizeMake(0, 0));
|
||||
let nativeSize = this._nativeView.sizeThatFits(zeroSize);
|
||||
this.width = nativeSize.width;
|
||||
this.height = nativeSize.height;
|
||||
|
||||
let widthAndState = layout.makeMeasureSpec(layout.toDevicePixels(nativeSize.width), layout.EXACTLY);
|
||||
let heightAndState = layout.makeMeasureSpec(layout.toDevicePixels(nativeSize.height), layout.EXACTLY);
|
||||
const widthAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.width), layout.toDevicePixels(51), layout.EXACTLY, 0);
|
||||
const heightAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.height), layout.toDevicePixels(31), layout.EXACTLY, 0);
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user