2016-12-02 93 views
1

是否有創建適合屏幕寬度的自定義alertController?ios swift 3 - UIAlertController width

我試過幾件事情問這個問題他們 一個是前:

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) 

但是這行代碼總是讓我alertController和屏幕之間的水平空間。

+3

UIAlertViewController旨在通過文檔使用。你最好的選擇是通過UIViewController自定義視圖,這樣你可以根據自己的需要設置寬度以及其他配置。 – DrPatience

回答

2

這是我目前發現在蘋果的文件:

警報瀏覽的外觀: 無法自定義的警報視圖的外觀。

這令我失望,因爲我認爲警報視圖中的消息文本對於很多用戶來說太小。 DrPatience在上面的評論中提出了一種可能的解決方法。 Alert Views