49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
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++``,
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,swift]
|
|
----
|
|
@IBInspectable // Noncompliant; type is implicit
|
|
public var cornerRadius = 2.0 {
|
|
didSet {
|
|
//...
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,swift]
|
|
----
|
|
@IBInspectable
|
|
public var cornerRadius: CGFloat = 2.0 {
|
|
didSet {
|
|
//...
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|