iOS上的轻量级弹出对话框



PR之后https://github.com/codenameone/CodenameOne/pull/3233,我得到我想要的弹出对话框(在Android上(。它们还可以,文本正确地在中间,边距和填充符都是我想要的。

但我对iOS有问题。有时,当弹出对话框包含的文本很少时,iOS会为对话框计算错误的维度。它只在iOS上发生。

我所理解的是,在iOS上对话框弹出窗口的实现是原生的,而在Android上它是轻量级的。如果我误解了,请纠正我。由于Android的实现效果很好,我也想在iOS上使用它。这就是我的RFE的含义:https://github.com/codenameone/CodenameOne/issues/3234

无论如何,我改变了我的问题:即使没有RFE,我也可以在iOS上使用轻量级弹出对话框吗?

是的,但这可能有点棘手。如果你使用CSS设置弹出框会因为这个问题而变得非常痛苦。

因此,您需要使用设计器工具并定义PopupDialog来显式使用RoundRectBorder,或者您需要从代码中执行此操作(将其显式设置到主题中(。

一个可能有效的黑客攻击(没有尝试过(是在您的init(Object)而不是initFirstTheme:中使用此代码

try {
theme = Resources.openLayered(resourceFile); 
themeProps.put("PopupDialog.derive", "Dialog");
themeProps.put("PopupDialog.border", RoundRectBorder.create().
cornerRadius(2f).
shadowOpacity(60).shadowSpread(3.0f));
themeProps.put("PopupDialog.transparency", "255");
themeProps.put("PopupDialog.bgColor", background);
themeProps.put("PopupDialog.padding", "4,4,4,4");
themeProps.put("PopupDialog.padUnit", new byte[]{Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS});
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
Resources.setGlobalResources(theme);
} catch(IOException e){
Log.e(e);
}

最新更新