作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想重新创建 AppStore 的“今日”卡片,其中包含圆角和浅色阴影。
我创建了一个路径、一个 maskLayer 和一个单独的 shadowLayer,根据多个消息来源,这是实现它的方式。
然而,问题是我可爱的带阴影的圆角矩形在它的角上有一些灰色笔触。我该如何解决这个问题?我尝试了不同的阴影不透明度和不同的半径。它没有解决我的问题。
在这里您可以看到我的屏幕截图和下面的代码。
override func loadView() {
let view = UIView()
view.backgroundColor = .white
self.view = view
// create sample view and add to view hierarchy
let bigTeaser = UIView(frame: CGRect(x: 16, y: 200, width: 343, height: 267))
bigTeaser.backgroundColor = UIColor.white
view.addSubview(bigTeaser)
// create the path for the rounded corners and the shadow
let roundPath = UIBezierPath(roundedRect: bigTeaser.bounds, cornerRadius: 20)
// create maskLayer
let maskLayer = CAShapeLayer()
maskLayer.frame = bigTeaser.bounds
maskLayer.path = roundPath.cgPath
bigTeaser.layer.mask = maskLayer
// create shadowLayer
let shadowLayer = CAShapeLayer()
shadowLayer.path = roundPath.cgPath
shadowLayer.frame = bigTeaser.frame
shadowLayer.shadowOpacity = 0.3
shadowLayer.shadowRadius = 24
shadowLayer.shadowColor = UIColor.black.cgColor
shadowLayer.shadowOffset = CGSize(width: 0, height: 2)
// insert layers
bigTeaser.superview!.layer.insertSublayer(shadowLayer, below: bigTeaser.layer)
}
最佳答案
如果你替换:
shadowLayer.path = roundPath.cgPath
到
shadowLayer.shadowPath = roundPath.cgPath
丑陋的边框会神奇地消失。
关于swift - bezierpath View 上的阴影为角落添加了奇怪的笔触,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55160105/
我试图找到这些三角形角的像素值。我可以使用 Harris 角并获得角的所有 x、y 的 numpy 数组。我希望将这些角值存储在称为角的二维列表中,如 [[x1,y1], [x2,y2], [x3,y
我的谷歌地图实例中的信息窗口看起来很有趣: 构成信息窗口图形角落和末端的某些图像似乎丢失了。知道为什么会这样吗?我正在尝试,但还没有弄清楚。 我正在使用 gmap3 ,一个用于 google 的 V3
我有一个带有动态添加和删除选项卡的 QTabWidget。我还有一个 QToolButton 设置为角落小部件,以便处理其 clicked() 信号上的添加事件。 虽然添加效果非常好,但从小部件中删除
我是一名优秀的程序员,十分优秀!