Reputation:
While attempting to modify the Apple tutorial found here on IBinspectable properties for my own project I have run into a major roadblock.
I defined a simple button subclass:
import UIKit
@IBDesignable public class SocialMediaLoginButton: UIButton {
private var _loginType: SocialMediaLoginType = .facebook
@IBInspectable public var loginType: SocialMediaLoginType
= SocialMediaLoginType.facebook {
didSet {
self._loginType = loginType
}
}
}
And then added a UIButton to my storyboard which I then selected the CustomClass as the above type. When I switch over to the Attributes inspector the property is not there for me to adjust. I have no idea what is going on:
I have looked up other questions however there are either extremely outdated or have no answers on the app developer forum.
I have tried:
None of these have worked. I am at a loss for how to fix this. I am using Xcode 8.3.3
Upvotes: 11
Views: 2553
Reputation: 924
To add to Wilson answer, you MUST EXPLICITLY specify the type (Int, String, etc.) for it to show.
Upvotes: 8
Reputation: 616
Interface Builder supports the inspection of basic types (and their corresponding optionals), including: Booleans, numbers, strings, as well as CGRect, CGSize, CGPoint, and UIColor.
I think your type does not work with interface builder.
Upvotes: 9