我不明白如何刪除添加到視圖中的陰影。 我添加到我的觀點在initWithFrame
陰影中這樣說:iOS從視圖中添加/刪除陰影
self.layer.borderWidth = 2;
self.layer.borderColor = [UIColor clearColor].CGColor;
self.backgroundColor = [UIColor greenColor];
[self.layer setCornerRadius:8.0f];
CALayer *layer = self.layer;
layer.shadowOffset = CGSizeMake(2, 2);
layer.shadowColor = [[UIColor blackColor] CGColor];
layer.cornerRadius = 8.0f;
layer.shadowRadius = 3.0f;
layer.shadowOpacity = 0.80f;
layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath];
後在應用程序的執行我想從該視圖中刪除的影子。我已經嘗試使用:
layer.hidden = YES;
或
self.layer.hidden = YES;
但這完全隱藏的觀點,而不僅僅是添加陰影。
有沒有辦法從視圖中檢索添加的陰影,然後隱藏它? 謝謝!
是否有原因你在代碼的中間聲明瞭一個指向'self.layer'的本地'layer'變量? –
我讀過這可能是更好的性能原因聲明與UIBezierPath的shadowPath,不是嗎?有最佳做法來做到這一點? –