2021-04-28 16:49:39 +02:00
Adding ``++IBInspectable++`` to a properly-typed variable makes it available in Xcode's Interface Builder. But that only works if variable type is declared explicitly as one of the following:
* ``++Int++`` types, ``++Double++``, ``++Float++``, ``++Bool++``
* ``++String++`` (or its optional)
* ``++CGFloat++``, ``++CGPoint++``, ``++CGSize++``, ``++CGRect++``
* ``++UIColor++``, ``++UIImage++`` (and their optionals)
* ``++NSString++``, ``++NSColor++``, ``++NSImage++`` (and their optionals)
* ``++NSRect++``, ``++NSPoint++``, ``++NSSize++``,
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
@IBInspectable // Noncompliant; type is implicit
public var cornerRadius = 2.0 {
didSet {
//...
}
}
----
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
@IBInspectable
public var cornerRadius: CGFloat = 2.0 {
didSet {
//...
}
}
----
2021-04-28 18:08:03 +02:00
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
endif::env-github,rspecator-view[]