3

Is there anyway to create a custom alertController that fit the width of the screen ?

I tried several things before asking this question one of them is :

let width:NSLayoutConstraint = NSLayoutConstraint(item: alertController.view, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: view.bounds.width )

alertController.view.addConstraint(width)

But this line of code always makes a horizontal space between my alertController and the Screen.

Anthony Shahine
  • 2,477
  • 3
  • 18
  • 24
  • 3
    the UIAlertViewController is intended to be used as is via the documentation. You best alternative is to make a custom view yourself via a UIViewController, that way you can set the width as you please as well as other configurations. – DrPatience Dec 02 '16 at 14:35
  • the solution to change the width https://stackoverflow.com/questions/26774038/how-to-set-height-and-width-of-a-uialertcontroller-in-ios-8/58387922#58387922 the solution to change the height https://stackoverflow.com/a/28425323/11054805 – joy son Aug 17 '20 at 09:11

1 Answers1

2

Here is what I currently find in the Apple documents:

Appearance of Alert Views: You cannot customize the appearance of alert views.

This disappoints me as I think the message text in alert views is too small for many users. DrPatience, in a comment above, suggests a possible workaround. Alert Views

WPWPWP
  • 363
  • 4
  • 15