如何使用 CosmicMinds 材质库减少材质 Textfield 中动画占位符文本的空间?
Posted
技术标签:
【中文标题】如何使用 CosmicMinds 材质库减少材质 Textfield 中动画占位符文本的空间?【英文标题】:how to reduce the space of animated placeholder text in material Textfield using CosmicMinds Material library? 【发布时间】:2017-06-02 11:20:09 【问题描述】:我正在为我的一个项目使用 CosmicMinds 材质库。我面临一个悬停文本问题。我想减少我无法弄清楚的空间。Attached Image
我的示例代码:
func prepareChangePasswordField()
enterPasswordText.placeholder = "Password"
enterPasswordText.detailColor = Color.red
enterPasswordText.delegate = self
enterPasswordText.placeholderNormalColor = UIColor.lightGray
enterPasswordText.placeholderActiveColor = Color.blue.base
enterPasswordText.dividerNormalColor = Color.grey.base
enterPasswordText.dividerActiveColor = Color.blue.base
enterPasswordText.isVisibilityIconButtonEnabled = true
enterPasswordText.visibilityIconButton?.tintColor = Color.grey.base.withAlphaComponent(passwordText.isSecureTextEntry ? 0.2 : 1.0)
func prepareConfirmPasswordField()
confirmPasswordText.placeholder = "Confirm password"
confirmPasswordText.detailColor = Color.red
confirmPasswordText.delegate = self
confirmPasswordText.placeholderNormalColor = UIColor.lightGray
confirmPasswordText.placeholderActiveColor = Color.blue.base
confirmPasswordText.dividerNormalColor = Color.grey.base
confirmPasswordText.dividerActiveColor = Color.blue.base
confirmPasswordText.isVisibilityIconButtonEnabled = true
confirmPasswordText.visibilityIconButton?.tintColor = Color.grey.base.withAlphaComponent(passwordText.isSecureTextEntry ? 0.2 : 1.0)
//self.view.addSubview(userNameText)
//view.layout(emailTextField).center(offsetY: -passwordField.height - 60).left(20).right(20)
【问题讨论】:
【参考方案1】:您尝试过placeholderVerticalOffset
属性吗?
【讨论】:
textField.placeholderVerticalOffset = 15
非常适合我。以上是关于如何使用 CosmicMinds 材质库减少材质 Textfield 中动画占位符文本的空间?的主要内容,如果未能解决你的问题,请参考以下文章