美文网首页
[iOS Swift] UIButton的阴影设置

[iOS Swift] UIButton的阴影设置

作者: ThomasRobot | 来源:发表于2016-11-24 19:02 被阅读490次

代码先行

// 定义阴影颜色
button.layer.shadowColor = UIColor.black.cgColor
// 阴影的模糊半径
button.layer.shadowRadius = 2.0
// 阴影的偏移量
button.layer.shadowOffset = CGSize(width: 0, height: 1)
// 阴影的透明度,默认为0,不设置则不会显示阴影****
button.layer.shadowOpacity = 0.7

iOS中阴影的概念

阴影组成的三要素

  • x偏移量:阴影相对于图形本身在水平方向的偏移量。
  • y偏移量:阴影相对于图形本身在垂直方向的偏移量。
  • 模糊度:阴影的柔和程度。

详细可官方文档:shadow

相关文章

网友评论

      本文标题:[iOS Swift] UIButton的阴影设置

      本文链接:https://www.haomeiwen.com/subject/ycxipttx.html