Skip to content

Commit

Permalink
Update README.md for using text fields in alerts
Browse files Browse the repository at this point in the history
This includes instructions for variations on text field initialization and chaining text fields with other Alert methods.
  • Loading branch information
akwilliamson committed Jul 27, 2015
1 parent 51c4fb9 commit c65eb3b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ There is also a shortcut for quickly showing an alert with an `Okay` button. Aft
Alert(title: "Stuff has happened").showOkay()
```

Text fields can be added to instances of the Alert class. Text fields are blank and do not have secure text entry by default, but placeholder text and/or secure text entry can be optionally configured through initialization.

``` Swift
Alert.addTextfield()
Alert.addTextfield(placeholder: "Enter Username")
Alert.addTextfield(secureText: true)
Alert.addTextfield(placeholder: "Enter Password", secureText: true)
```

Adding text fields can be strung together with other Alert methods.

``` Swift
Alert(title: "Title", message: "Message")
.addTextField(placeholder: "Enter Username")
.addTextField("Enter Password", secureText: true)
.addAction("Cancel")
.addAction("Submit", style: .Default) { action in
logInMethod()
}
.show()
```

##Testing

You can add an override for the `show` method to make it easy to add unit tests for your alerts.
Expand Down

0 comments on commit c65eb3b

Please sign in to comment.