1
我需要通知用戶,但我不喜歡標準的UIAlertController設計,我需要用我的背景圖像和自定義顏色顯示通知,以便我的應用程序的每個窗口小部件都處於相同樣式。如何爲UIAlertController設置圖像?
我有什麼選擇?
我可以簡單地實現自定義視圖並以模態方式呈現嗎? 你能指點我一個很好的教程嗎?
我需要通知用戶,但我不喜歡標準的UIAlertController設計,我需要用我的背景圖像和自定義顏色顯示通知,以便我的應用程序的每個窗口小部件都處於相同樣式。如何爲UIAlertController設置圖像?
我有什麼選擇?
我可以簡單地實現自定義視圖並以模態方式呈現嗎? 你能指點我一個很好的教程嗎?
可以在一定程度上定製UIAlertController
就像你可以改變它的tintcolor
,可以設置attributed title
,可以設置image
等一樣,
alertController.view.tintColor = [UIColor black]; //tint color
NSMutableAttributedString *attributedString= [[NSMutableAttributedString alloc] initWithString:@"your string"];
[attributedString addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:40.0]
range:NSMakeRange(3, 7)];
[alertController setValue:attributedString forKey:@"attributedTitle"];
UIAlertAction *action= [UIAlertAction actionWithTitle:@"title"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
}];
UIImage *img= [UIImage imageNamed:@"imagename"];
[action setValue:img forKey:@"image"];
但如果你想完全自定義alertcontroll
,那麼你應該使用單獨的uiview
或viewcontroller
並應該呈現它!你可以參考nhhipster's tutorial知道如何玩alertcontroll
。
謝謝你,我會嘗試一下,如果一切都好,我會接受你的答案,順便說一句,你可以寫在迅速,我不熟悉對象C語法 –
我會盡快更新它在迅速可能! – Lion