用下面的代碼片段,我將一個陰影效果添加到我的UIView中。這工作得很好。但只要我將視圖的掩碼到邊框屬性設置爲是。陰影效果不再呈現。爲什麼masksToBounds = YES會阻止CALayer的影子?
self.myView.layer.shadowColor = [[UIColor blackColor] CGColor];
self.myView.layer.shadowOpacity = 1.0;
self.myView.layer.shadowRadius = 10.0;
self.myView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
self.myView.layer.cornerRadius = 5.0;
self.myView.layer.masksToBounds = YES; // <-- This is causing the Drop shadow to not be rendered
UIBezierPath *path = [UIBezierPath bezierPathWithCurvedShadowForRect:self.myView.bounds];
self.myView.layer.shadowPath = path.CGPath;
self.myView.layer.shouldRasterize = YES;
您對此有何看法?
該死!這就說得通了! – jchatard 2010-09-11 13:22:18
非常感謝你......這對我非常有幫助。感激你.. :) – innodeasapps 2012-08-20 10:23:04
樂意幫忙! – TheSquad 2012-08-22 18:02:27