https://github.com/zhangyanlf/newofo
https://github.com/zhangyanlf/newofo
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zhangyanlf/newofo
- Owner: zhangyanlf
- License: mit
- Created: 2018-05-15T08:40:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T07:44:22.000Z (almost 7 years ago)
- Last Synced: 2025-01-09T14:40:29.406Z (5 months ago)
- Language: Swift
- Size: 10.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# newOfO
# UIVIew设置圆角及阴影效果展示具体效果
- 首先创建Swift file 对UIView进行扩展``` iOS
extension UIView {
@IBInspectable
var cornerRadius : CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
}
}
//阴影圆角
@IBInspectable
var shadowRadius : CGFloat {
get {
return layer.shadowRadius
}
set {
layer.shadowRadius = newValue
}
}
//阴影偏移
@IBInspectable
var shadowOffset : CGSize {
get {
return layer.shadowOffset
}
set {
layer.shadowOffset = newValue
}
}
//阴影颜色
@IBInspectable
var shadowColor : UIColor? {
get {
return layer.shadowColor != nil ? UIColor(cgColor: layer.shadowColor!) : nil
}
set {
layer.shadowColor = newValue?.cgColor
}
}
//阴影透明度
@IBInspectable
var shadowOpacity : Float {
get {
return layer.shadowOpacity
}
set {
layer.shadowOpacity = newValue
}
}
```
> @IBInspectable 可以使设置的属性直接显示在Storyboard面板中,见项目效果:- 属性设置可以及时在Storyboard中看到效果(当前设置View的Class设置为ArcView)
```iOS
@IBDesignable
class ArcView: UIView {
}
```> @IBDesignable 在Storyboard中及时看到效果(阴影效果)