Reputation: 4632
I have a UIAlertController
of .alert
style with message text. I have inserted a UITextFiled
in it with addTextField(....
and now I want a string of text below it. I assume I need a UILabel
but how do I insert it?
Upvotes: 2
Views: 4381
Reputation: 11494
A UIAlertController
sub-classes from UIViewController
. Because of this, a UIAlertController
contains a view which can be modified. So, to add a label to the alert, you could do this:
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
label.text = "Text"
alert.view.addSubview(label)
However, you should keep in mind what is said in the docs:
The UIAlertController class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
Upvotes: 3