是否有可能animationUIEdgeInsets?
我一直试图在UIEdgeInsets
改变animation。 我已经尝试使用UIView.animateWithDuration
和insets只是跳转到最后的值。 有没有人知道这是一个不能animation的属性? 或者更好的是,是否有人知道一个animation内嵌的方法?
举个例子:
// 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
.textAlignment
为.Center
,但不会animation。
您需要在animation块内的视图上调用layoutIfNeeded()
。