Storyboard에서 UIView의 테두리, 모서리, 그림자를 설정하는 Extension
                                            
                                                
                                                
                                                
                                                
                                                
                                                 7284 단어  iOSSwiftXcodestoryboardtech
                    
컨디션
UIView의 Extension
설정
@IBInspectable의 모방을 통해 사용자 정의 속성을 추가할 수 있습니다.import UIKit
extension UIView {
  // MARK: Utility
  /// 枠線の色
  @IBInspectable var borderColor: UIColor? {
    get {
      layer.borderColor.map { UIColor(cgColor: $0) }
    }
    set {
      layer.borderColor = newValue?.cgColor
    }
  }
  /// 枠線のWidth
  @IBInspectable var borderWidth: CGFloat {
    get {
      layer.borderWidth
    }
    set {
      layer.borderWidth = newValue
    }
  }
  /// 角丸の大きさ
  @IBInspectable var cornerRound: CGFloat {
    get {
      layer.cornerRadius
    }
    set {
      layer.cornerRadius = newValue
      layer.masksToBounds = newValue > 0
    }
  }
  /// 影の色
  @IBInspectable var shadowColor: UIColor? {
    get {
      layer.shadowColor.map { UIColor(cgColor: $0) }
    }
    set {
      layer.shadowColor = newValue?.cgColor
      layer.masksToBounds = false
    }
  }
  /// 影の透明度
  @IBInspectable var shadowAlpha: Float {
    get {
      layer.shadowOpacity
    }
    set {
      layer.shadowOpacity = newValue
    }
  }
  /// 影のオフセット
  @IBInspectable var shadowOffset: CGSize {
    get {
      layer.shadowOffset
    }
    set {
      layer.shadowOffset = newValue
    }
  }
  /// 影のぼかし量
  @IBInspectable var shadowRadius: CGFloat {
    get {
      layer.shadowRadius
    }
    set {
      layer.shadowRadius = newValue
    }
  }
}
Reference
이 문제에 관하여(Storyboard에서 UIView의 테두리, 모서리, 그림자를 설정하는 Extension), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/xxminamixx/articles/dc38f488e6ab15텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)