我一直在试图激活UIEdgeInsets的一个变化。我已经尝试过使用UIView.animateWithDuration,而insets只是跳转到最后的值。有没有人知道这是否是一个不能动画片的财产?或者更好的是,有没有人知道一种让嵌入式动画化的方法?
例如:
// Starting inset values
self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 110, bottom: 0, right: 10)
// Animation block
UIView.animateWithDuration(0.1, animations: {
self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 10)
})文本不是在0.1秒内向左移动92个像素,而是跳转到最后一个值。searchField是UITextField,.placeHolderInset是用来确定UITextField占位符文本内嵌的UIEdgeInset。
编辑:实现预期效果的另一种方法是将UITextField的.textAlignment从.Center更改为.Left,但这也不会产生动画效果。
发布于 2015-05-09 08:06:30
您需要在动画块内部的视图上调用layoutIfNeeded()。
https://stackoverflow.com/questions/30136973
复制相似问题