首页 > 解决方案 > 从文本字段 swift 4 中删除 rightView 属性

问题描述

如果文本字段中包含一些文本,我将使用 rightview 属性。如果文本字段不包含任何文本,我需要删除该属性。我搜索了很多链接,但没有找到任何答案。请帮我。

添加 rightView 属性

let cardImage = UIImageView(image: UIImage(named: icon))
cardImage.frame = CGRect(x: 10, y: 20, width: 70, height: self.cardTxtFld.frame.size.height-20);
cardImage.contentMode = UIViewContentMode.scaleAspectFit
self.cardTxtFld.rightView = cardImage;
self.cardTxtFld.rightViewMode = UITextFieldViewMode.always

标签: iosswiftuitextfield

解决方案


推荐阅读