두 개의 형제보기가 있습니다. 회색 라벨과 녹색 버튼이 아래에 있습니다. 웬일인지 색을 지우려면 label.backgroundColor
을 설정하고 label.layer.backgroundColor
을 회색으로 설정해야합니다. 버튼 색상은 녹색입니다. 화면에 회색이 표시 될 것으로 예상됩니다 (라벨이 버튼 위에 있으므로). 하지만 내가 보는 것은 녹색 (단추의 색)입니다. 왜?iOS :보기 배경색이 투명 할 때 레이어 배경색이 표시되지 않습니다.
편집 : 관련 코드
// in my custom cell
-(void)awakeFromNib
{
[super awakeFromNib];
// customize label
_label.layer.cornerRadius = 5;
_label.layer.backgroundColor = [UIColor grayColor].CGColor;
_label.backgroundColor = [UIColor clearColor];
_label.layer.masksToBounds = NO;
// customize button
// show shadow and rounded corner at the same time
_button.backgroundColor = [UIColor clearColor];
_button.layer.backgroundColor = [UIColor greenColor].CGColor;
_button.layer.masksToBounds = NO;
_button.layer.cornerRadius = 10.0f;
self.layer.masksToBounds = NO;
self.layer.cornerRadius = 10.0f;
self.layer.shadowOpacity = 0.5f;
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:_button.bounds cornerRadius:10.0f].CGPath;
self.layer.shadowOffset = CGSizeMake(0.0f, 4.0f);
self.layer.shadowRadius = 2.0f;
}
"어떤 이유로"왜? 우리가 당신의 결정 뒤에 근거를 알면, 우리는 당신을 더 잘 도울 수 있습니다. – duci9y
여기에 relavent 코드를 넣으세요 :) – iPatel
'label.layer.masksToBounds = NO'를 유지하면서 라벨의 모서리를 둥글게해야하기 때문에 (그렇지 않으면 스크롤이 심각하게 뒤틀리게됩니다). 따라서 유일한 옵션은'label.backgroundColor' 대신'label.layer.backgroundColor'를 설정하는 것입니다. – Philip007