2016-10-18 22 views
3

我將Chameleon添加到項目中,並且大部分工作正常。在爲項目設置主題時偶然發現的一個問題是放置在UITableViewCell附件上的背景。移除UITableViewAccessory上的背景色

這裏就是我的附件看起來像啓用ChameleonFramework主題:

enter image description here

我所需配件的顏色是藍色的,沒有背景。變色龍似乎顛倒了這些。

我也打開了Debug View Hierarchy來看看發生了什麼。我可以「看到」的問題,但我無法弄清楚如何在附件視圖的背景去改回UIColor.white,我也不能弄清楚如何對號更改爲UIColor.blue

enter image description here

我試過在cellForRowAtIndexPath用下面的命令配件的色調鼓搗:

cell.tintColor = UIColor.blue 

我也試圖改變accessoryView背景:

cell.accessoryView!.tintColor = UIColor.blue 
cell.accessoryView?.backgroundColor = UIColor.white 

我也試圖改變tableView的色調:

tableView.tintColor = UIColor.blue 

任何其他的想法如何我會去改變這個是極大的讚賞。

+0

嘗試使用cell.accessoryView?.backgroundColor = UIColor.clearColor() – PrafulD

+0

感謝。我已經嘗試過了。 – Adrian

回答

0

顯然,這是一個變色龍的錯誤,目前正在研究中。

在調試視圖層次結構中進行挖掘時,看到對勾被繪製爲UIButton。在MyViewController中,我選擇了在AppDelegate中更改UIButton類的外觀,而不是將它包含在UITableViewCell中。

我能夠通過調用AppDelegate中下面的命令來解決我的問題:

UIButton.appearance(whenContainedInInstancesOf: [UITableViewCell.classForCoder() as! UIAppearanceContainer.Type]).backgroundColor = UIColor.clear 
    UIButton.appearance(whenContainedInInstancesOf: [UITableViewCell.classForCoder() as! UIAppearanceContainer.Type]).tintColor = FlatBlue() 
1

當使用Chameleon-RCI 2.1.0.2Xamarin我使用UITableViewCellAccessory.DetailDisclosureButton時有同樣的問題。

UITableViewCell cell = tableView.DequeueReusableCell("A"); 
if (cell == null) 
{ 
     cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "A"); 
     cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton; 
} 

阿德里安的答案,但與C#類似的修復是在AppDelegate類以下。

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) 
{ 
    // Override point for customization after application launch. 
    // If not required for your application you can safely delete this method 

    UIColor secondaryColor = ChameleonColor.FlatWatermelon; 
    Chameleon.SetGlobalTheme(ChameleonColor.FlatMint, secondaryColor, ContentStyle.Contrast); 

    UIButton.UIButtonAppearance buttonAppearance = UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UITableViewCell) }); 
    buttonAppearance.BackgroundColor = UIColor.Clear; 
    buttonAppearance.TintColor = secondaryColor; 

    return (true); 
}