I want to add a button with text "..." inside my UITextField. What i'm trying is the following:
@IBOutlet weak var requestTitleTxtField: UITextField!
viewDidLoad():
var detailsButton = UIButton()
detailsButton.titleLabel!.text = "..."
requestTitleTxtField.rightViewMode = UITextFieldViewMode.Always
requestTitleTxtField.rightView = detailsButton
This is not returning any error message but isn't showing the button either.
Create the button with frame:
var detailsButton = UIButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
Use detailsButton.setTitle("...", forState: .Normal)
to set the title.
You may also need to set color for the text:
detailsButton.setTitleColor(UIColor.redColor(), forState: .Normal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With