2014-10-08 70 views
1

與iOS8一樣UIAlertView已棄用。我們應該使用UIAlertController。 我想定製它像alertcontrller的視圖的字體顏色,消息標籤的字體家族,也改變ok按鈕的背景顏色。我不知道正確的方式來做到這一點。在iOS8中自定義UIAlertController

請幫忙!!

任何幫助將是可觀的!

在馬特·湯普森的網站
+0

是你可以定製u需要在子視圖循環,改變按您的要求的uialert ...並請出示你的,問不問呆呆怎麼... – Spynet 2014-10-08 05:02:14

+0

呀謝謝!但沒有比循環更好的解決方案嗎? – 2014-10-08 05:02:54

+0

或者你控制子類或者只是去定製視圖 – Spynet 2014-10-08 05:04:33

回答

1
+0

謝謝@Steve Rosenberg.but你可以給我鏈接Objective-C。 – 2014-10-08 05:07:51

+0

http://pivotallabs.com/uialertcontroller-ios-8/當然蘋果網站是在Obj C和Swift – 2014-10-08 05:09:37

+0

http://hayageek.com/uialertcontroller-example-ios/ – 2014-10-08 05:11:23

2

我想,你有與他們一起執行任務。但我認爲這對某人有用。

下面的代碼是完全符合我的要求。請根據您的要求進行更改。

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil 
                     message:nil 
                    preferredStyle:UIAlertControllerStyleActionSheet]; 

UIAlertAction *setCoverPhoto = [UIAlertAction 
           actionWithTitle:@"First Button" 
           style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction *action){ 

            NSLog(@"First Button"); 

           }]; 
[alertController addAction:setCoverPhoto]; 


UIAlertAction *deleteImageAct = [UIAlertAction 
           actionWithTitle:@"Second Button" 
           style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction *action) { 

            NSLog(@"Second Button"); 

           }]; 
[alertController addAction:deleteImageAct]; 

UIAlertAction *setImageASNotif = [UIAlertAction 
            actionWithTitle:@"Third Button" 
            style:UIAlertActionStyleDefault 
            handler:^(UIAlertAction *action) { 

             NSLog(@"Third Button"); 

            }]; 
[alertController addAction:setImageASNotif]; 


alertController.view.tintColor = [UIColor whiteColor]; 

UIView *subView = alertController.view.subviews.firstObject; 
UIView *alertContentView = subView.subviews.firstObject; 
[alertContentView setBackgroundColor:[UIColor darkGrayColor]]; 

alertContentView.layer.cornerRadius = 5; 

[self presentViewController:alertController animated:YES completion:nil]; 
相關問題