IBInspectable should use proper typing This product is not supported for your selected
Datadog site . (
).
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください 。
このルールを試す ID: swift-code-style/ibinspectable
Language: Unknown
Severity: Notice
Category: Best Practices
Description Properties of @IBInspectable
attribute must use the correct data type. This rule is vital because using the correct data type for @IBInspectable
properties can prevent runtime errors and misbehavior of the application. It also ensures that the properties are correctly displayed and editable in Interface Builder, which aids in the visual design of the user interface.
Non-Compliant Code Examples import UIKit
@IBDesignable
class CustomView : UIView {
@IBInspectable var cornerRadius : Foobar = 0 {
didSet {
self . layer . cornerRadius = cornerRadius
self . layer . masksToBounds = cornerRadius > 0
}
}
}
@IBInspectable
public var foobar = 2.0 {
}
Compliant Code Examples import UIKit
@IBDesignable
class CustomView : UIView {
@IBInspectable var cornerRadius : CGFloat = 0 {
didSet {
self . layer . cornerRadius = cornerRadius
self . layer . masksToBounds = cornerRadius > 0
}
}
@IBInspectable var borderWidth : CGFloat = 0 {
didSet {
self . layer . borderWidth = borderWidth
}
}
@IBInspectable var borderColor : UIColor = UIColor . clear {
didSet {
self . layer . borderColor = borderColor . cgColor
}
}
@IBInspectable var shadowColor : UIColor = UIColor . black {
didSet {
self . layer . shadowColor = shadowColor . cgColor
}
}
@IBInspectable var shadowOpacity : Float = 0 {
didSet {
self . layer . shadowOpacity = shadowOpacity
}
}
@IBInspectable var shadowOffset : CGSize = CGSize ( width : 0 , height : 0 ) {
didSet {
self . layer . shadowOffset = shadowOffset
}
}
@IBInspectable var shadowRadius : CGFloat = 0 {
didSet {
self . layer . shadowRadius = shadowRadius
}
}
}
シームレスな統合。 Datadog Code Security をお試しください