EXTENSION
public extension UIView
var anchorPoint: CGPoint
Set anchor point on layer
@IBInspectable var layerCornerRadius: CGFloat
Set corner radius on layer
@IBInspectable var layerBorderWidth: CGFloat
Set border width on layer
@IBInspectable var layerBorderColor: UIColor?
Set a border color on layer
func addCleanBorder(cornerRadius: CGFloat, color: UIColor, width: CGFloat, targetBounds: CGRect?)
Add border using path
- Parameters:
- cornerRadius: radius
- color: color
- width: width
- targetBounds: bounds or view bounds
Name | Description |
---|---|
cornerRadius | radius |
color | color |
width | width |
targetBounds | bounds or view bounds |
func addCleanBorder(roundingCorners: UIRectCorner, cornerRadii: CGSize, color: UIColor, width: CGFloat, targetBounds: CGRect?)
Add border using path
- Parameters:
- roundingCorners: Corners to round
- cornerRadii: radius
- color: color
- width: width
- targetBounds: view bounds
Name | Description |
---|---|
roundingCorners | Corners to round |
cornerRadii | radius |
color | color |
width | width |
targetBounds | view bounds |
func addTransparentGradientLayer(frame: CGRect? = nil, toColor: UIColor, minAlpha: CGFloat, maxAlpha: CGFloat, from start: GradientLayerChangingDirection, to end: GradientLayerChangingDirection) -> CAGradientLayer
Add a transparent gradient layer
- Parameters:
- frame: View frame (default to bounds)
- toColor: Color to add
- minAlpha: Alpha
- maxAlpha: End alpha
- start: Start direction
- end: End direction
Name | Description |
---|---|
frame | View frame (default to bounds) |
toColor | Color to add |
minAlpha | Alpha |
maxAlpha | End alpha |
start | Start direction |
end | End direction |
func sizeToFitConstraintedBasedLayout()
Resizes self.frame
so as to fit the constraint-based layout.
func shakeToIndicateError()
Commit a shake animation and vibrate to indicate the occured error.
func dropRealShadow(shadowColor: UIColor = UIColor.black, fillColor: UIColor = UIColor.white, opacity: Float = 0.2, offset: CGSize = CGSize(width: 0.0, height: 1.0), radius: CGFloat = 10) -> CAShapeLayer
New drop shadow by adding new layer
- Parameters:
- shadowColor: color
- fillColor: fill default: white
- opacity: opacity default 20%
- offset: offset default y: 1
- radius: radius (blur) default 10
- Returns: new layer
Name | Description |
---|---|
shadowColor | color |
fillColor | fill default: white |
opacity | opacity default 20% |
offset | offset default y: 1 |
radius | radius (blur) default 10 |
func dropShadow(color: UIColor, opacity: Float = 0.5, offSet: CGSize, radius: CGFloat = 1, scale: Bool = true)
Draw a simple drop shadow for the views layer
- Parameters:
- color: color
- opacity: opacity default: 50%
- offSet: offset
- radius: radius (blur) default 1
- scale: scale default: true
Name | Description |
---|---|
color | color |
opacity | opacity default: 50% |
offSet | offset |
radius | radius (blur) default 1 |
scale | scale default: true |
func fillParent(view: UIView, with insets: UIEdgeInsets = .zero)
Constrain view to parent view
- Parameters:
- view: Parent view
- insets: Margin insets
Name | Description |
---|---|
view | Parent view |
insets | Margin insets |
static func clear() -> UIView
Create a view with a clear background
- Returns: UIView