【发布时间】:2014-02-28 08:19:58
【问题描述】:
我已经实现了一个看起来像这样的视图 -
但我希望视图的底部看起来像这样 -
添加阴影无济于事,因为只要我这样做maskToBounds = YES,我就会得到第一张照片中的内容。这是我到目前为止的代码
[self.contentView.layer setCornerRadius:3.0f];
UIColor* color = CardBorderColor; // this is a macro that defines the color
[self.contentView.layer setBorderColor:color.CGColor];
[self.contentView.layer setBorderWidth:1.0f];
[self.contentView.layer setShadowColor:color.CGColor];
[self.contentView.layer setShadowOpacity:1.0];
[self.contentView.layer setShadowRadius:3.0];
[self.contentView.layer setShadowOffset:CGSizeMake(1.0, 1.0)];
self.contentView.layer.masksToBounds = YES;
【问题讨论】:
-
哇,我不知道为什么有人投了反对票。完全合法的问题。 (我投票 +1 将其设为 0。)您绝对需要 maskToBounds = YES 吗?如果您需要将它用于另一个元素,请尝试将需要 maskToBounds 的视图放在另一个视图中,并将阴影添加到底部视图。
标签: ios iphone objective-c uiview core-graphics