最近想要在項目更好的優(yōu)化下UI 試著去改系統(tǒng)自帶的UIAlertController的彈出框顏色 枫夺,卻發(fā)現(xiàn)只有自己寫的才能修改顏色姊途,而系統(tǒng)自動調用的卻無論怎么做都無法修改。
UIAlertController *abc = [UIAlertControlleralertControllerWithTitle:@"800-820-8820"message:nilpreferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ac1 = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction*_Nonnullaction) {
}];
[ac1 setValue:kMainBaseColorforKey:@"_titleTextColor"];
[abcaddAction:ac1];
self.view.tintColor=kMainBaseColor;
UIAlertAction*ac2 = [UIAlertActionactionWithTitle:@"呼叫"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction*_Nonnullaction) {
}];
[ac2setValue:kMainBaseColorforKey:@"_titleTextColor"];
[abcaddAction:ac2];
[selfpresentViewController:abcanimated:YEScompletion:^{
}];
這是自己寫的UIAlertController频丘。使用的KVC模式去修改的UIAlertAction的字體顏色 這個方法是可行的辜梳。
而系統(tǒng)自動調用的卻無法更改, 想使用RunTime去修改 卻對RunTime機制還是不夠了解胜宇。唉耀怜!
最后想的是如果能獲取到這個UIAlertController 那么不就可以去遍歷所有的子控件來修改賦值嗎? 想到就去做桐愉。結果卻發(fā)現(xiàn)财破。。从诲。
這個是自己寫的UIAlertController 了就是上面的代碼左痢。 這種方式調用出來的是可以看到的 也是嵌入在app里面的。 然而 系統(tǒng)的卻不是系洛。
NSString * callString =[NSString stringWithFormat:@"tel://800-820-8820"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callString] options:@{}completionHandler:nil];
這種方法在iOS10.2系統(tǒng)會自動調用UIAlertController ??
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:callString]];
這種調用方法在iOS10以下的系統(tǒng)中調用撥打電話功能都是直接調用的? 并不會彈出UIAlertController
從這個圖層上可以看到抖锥,使用第二種[UIApplication sharedApplication] openURL這種方法調用的,并不會出現(xiàn)在app里面碎罚,這樣無法獲取到UIAlertController 無法去修改它的顏色。
這是控制臺輸出纳像,這個彈出框已經(jīng)脫離了app本身荆烈。
這只是我的個人見解,如有解決方法竟趾,請私信我憔购!謝謝
大家一起共同進步,共同成長岔帽。