Skip to content

Instantly share code, notes, and snippets.

@smhemel
Created December 10, 2018 06:15
Show Gist options
  • Save smhemel/1cb0e15fde4eb8694719f9996c74ce35 to your computer and use it in GitHub Desktop.
Save smhemel/1cb0e15fde4eb8694719f9996c74ce35 to your computer and use it in GitHub Desktop.

Revisions

  1. S M HEMEL created this gist Dec 10, 2018.
    57 changes: 57 additions & 0 deletions CustomUIILabelClass.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    // This file add your project and customize your Label.

    import UIKit

    @IBDesignable
    class UILabelX: UILabel {

    @IBInspectable var cornerRadius: CGFloat = 0 {
    didSet {
    self.layer.cornerRadius = cornerRadius
    }
    }

    @IBInspectable var borderWidth: CGFloat = 0.0 {
    didSet {
    self.layer.borderWidth = borderWidth
    }
    }

    @IBInspectable var borderColor: UIColor = UIColor.clear {
    didSet {
    self.layer.borderColor = borderColor.cgColor
    }
    }

    @IBInspectable var rotationAngle: CGFloat = 0 {
    didSet {
    self.transform = CGAffineTransform(rotationAngle: rotationAngle * .pi / 180)
    }
    }

    // MARK: - Shadow Text Properties

    @IBInspectable public var shadowOpacity: CGFloat = 0 {
    didSet {
    layer.shadowOpacity = Float(shadowOpacity)
    }
    }

    @IBInspectable public var shadowColorLayer: UIColor = UIColor.clear {
    didSet {
    layer.shadowColor = shadowColorLayer.cgColor
    }
    }

    @IBInspectable public var shadowRadius: CGFloat = 0 {
    didSet {
    layer.shadowRadius = shadowRadius
    }
    }

    @IBInspectable public var shadowOffsetLayer: CGSize = CGSize(width: 0, height: 0) {
    didSet {
    layer.shadowOffset = shadowOffsetLayer
    }
    }
    }