2012-12-18 30 views

回答

11

您不能使用UIAppearance來自定義UIAlertView

UIAlertView僅示出了爲具有UIAppearance因爲UIView符合UIAppearanceUIAlertViewUIView一個子類。

雖然它並沒有實際實現。

0

如果你想定製UIAlertView,我做了UIAlertView的子類,你可以在github上找到它,它支持類似於UIAppearance的代理。您可以使用它來爲所有WCAlertView設置默認值:

[WCAlertView setDefaultCustomiaztonBlock:^(WCAlertView *alertView) { 
     alertView.labelTextColor = [UIColor colorWithRed:0.11f green:0.08f blue:0.39f alpha:1.00f]; 
     alertView.labelShadowColor = [UIColor whiteColor]; 

     UIColor *topGradient = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f]; 
     UIColor *middleGradient = [UIColor colorWithRed:0.93f green:0.94f blue:0.96f alpha:1.0f]; 
     UIColor *bottomGradient = [UIColor colorWithRed:0.89f green:0.89f blue:0.92f alpha:1.00f]; 
     alertView.gradientColors = @[topGradient,middleGradient,bottomGradient]; 

     alertView.outerFrameColor = [UIColor colorWithRed:250.0f/255.0f green:250.0f/255.0f blue:250.0f/255.0f alpha:1.0f]; 

     alertView.buttonTextColor = [UIColor colorWithRed:0.11f green:0.08f blue:0.39f alpha:1.00f]; 
     alertView.buttonShadowColor = [UIColor whiteColor]; 
}]; 
+0

您是否在AppStore中的應用程序中使用了這個功能?該文檔明確指出,UIAlertView不應該被分類,並打算按原樣使用:https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html – Jasper

相關問題