Text Field name programatically in swift 4

时间:2019-04-08 13:31:45

标签: swift xcode

I've below form:- enter image description here

I've created this form programatically. The code for this is below:-

   let textFiled = UITextField(frame:CGRectMake(87.0, y, 100.0, 20.0))
    textFiled.borderStyle = UITextBorderStyle.Line
     textFiled.font =  UIFont.systemFontOfSize(8)

Now if I set tag for these text field then it'll store Int value. Which is very tough for me to manipulate this form.

I want to set name like IBOutlet for each text field. So that I can easily handle this form.

Is it possible to do it in Swift 4...

I want Your opinion please....

1 个答案:

答案 0 :(得分:1)

Similar to tag, we have

accessibilityIdentifier

in which you can add String values you can just say

textFiled.accessibilityIdentifier = "name"

and get value using the below:-

textFiled.accessibilityIdentifier