钛合金之如何将 View 从 0 高度设置为 "auto"
zhengyun_ustc
阅读:134
2025-02-15 21:57:57
评论:0
在钛合金中,我希望将 View 从 0 的高度设置为“自动”或 Ti.UI.SIZE
的高度。 . View 包含一个标签,其中包含可以跨越多行的不同数量的文本,所以我需要 View 动画到它需要的高度,只是为了在其中显示标签。这个想法是你点击一个按钮,它动画 View 和文本滑动打开。类似于在网络上经常看到的 jQuery slideDown 动画。
我遇到的问题是,如果我尝试将动画设置为“自动”或 Ti.UI.SIZE
的高度,动画似乎根本没有发生。动画到固定高度是可行的,但我需要它对 View 的内容具有灵活性。
我的观点
<Button id="toggleBrandInfoBtn" onClick="toggleBrandInfo" title="Show Text" />
<View id="brandInfo" layout="vertical" height="0">
<Label id="brandInfoLabel" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor."></Label>
</View>
Controller
$.brandInfo.anchorPoint = {x:0, y:0};
$.toggleBrandInfoBtn.addEventListener("click", function () {
$.brandInfo.animate({
anchorPoint: {x:1, y:1},
top: 0,
height: Ti.UI.SIZE,
duration: 1000
});
});
请您参考如下方法:
您是否尝试过百分比值?这不一定有记录,但我已经取得了一些成功。还可以尝试 1% 的起始值。
$.brandInfo.anchorPoint = {x:0, y:0};
$.toggleBrandInfoBtn.addEventListener("click", function () {
$.brandInfo.animate({
anchorPoint: {x:1, y:1},
top: 0,
height: '100%',
duration: 1000
});
});
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。