我有一個UIView有幾個UIViews(view1-view10)和UILabels(label1-label3)作爲子視圖。標籤2位於視圖3的頂部,並且我已將label2的背景色設置爲清除,但我仍然在label2周圍獲得了一個白色框,從而阻擋了我的一些視圖3.我如何設置它以便非文本區域清楚了?我參加了一個屏幕截圖,並張貼在這裏:UILabel清除背景
UILabel * newLabel = [[UILabel alloc] initWithFrame:CGRectMake([[properties objectAtIndex:1] intValue], [[properties objectAtIndex:2] intValue], [[properties objectAtIndex:3] intValue], [[properties objectAtIndex:4] intValue])];
[newLabel setBackgroundColor:[UIColor clearColor]];
[self addSubview:newLabel];
將標籤的'backgroundColor'設置爲'[UIColor clearColor]'是正確的方法。顯示一些相關的代碼。 – rmaddy
您確定您正在設置正確標籤或所有標籤的背景顏色以清除?你可能正在查看一個你沒有設置背景顏色的。 – Jsdodgers
您在圖片中顯示的圖片不是您顯示代碼的圖片(您沒有爲在發佈代碼中創建的圖片設置任何文本,因此它不會說「在此輸入文本!」)。 – rdelmar