Questions tagged [ibinspectable]

IBInspectable is a keyword that enables a property to be set from Xcode Interface Builder.

IBInspectable is a keyword that enables a property to be set from Xcode Interface Builder.

Sample Objective-C usage:

@property IBInspectable float myCustomProperty;

Sample Swift usage:

@IBInspectable public var myCustomProperty:float = 1.0

See also:

131 questions
2
votes
2 answers

Create custom action in a class for use in Interface Builder

I want to create a custom action connection in a class, which should be visible in Interface Builder. For example - I add action / target properties to NSView class just like this: weak open var object: AnyObject? open var something:…
Ivaylo Nikolov
  • 501
  • 4
  • 13
2
votes
1 answer

IBDesignable for UIButton, IBInspectable vars are nil

I am having a strange problem with UIButton. I have the following custom class: import UIKit @IBDesignable class ToggleButton: UIButton { @IBInspectable var state1Image: UIImage = UIImage() @IBInspectable var state2Image: UIImage =…
Kex
  • 8,023
  • 9
  • 56
  • 129
2
votes
0 answers

At which order Interface Builder evaluates IBInspectables?

I have custom UI element designed with a help of IBInspectables, so that I can use and modify it in the Interface Builder. There are 2 inspectables which effectively change the same property of the element but in a slightly different manner. At…
markvasiv
  • 522
  • 2
  • 16
2
votes
4 answers

Swift IBInspectable didSet versus get/set

I am relatively new to IBDesignables and IBInspectable's and I noticed that a lot of tutorial use IBInspectable in this fashion. @IBInspectable var buttonBorderWidth: CGFloat = 1.0 { didSet { updateView() } } func updateView() { …
Saik
  • 993
  • 1
  • 16
  • 40
2
votes
1 answer

Use of setter getter from another view controller

I've already created a CustomView(.Xib) with it's class(.Swift). In order to reach it's views (widgets) property I've defined several getter and setter and for now I need to call them to modify but when I make an object from the class I can't modify…
Mamad Farrahi
  • 394
  • 1
  • 5
  • 20
2
votes
2 answers

Value of @IBInspectable set in storyboard not propagated to the code

Without any experience with iOS, I have been asked to upgrade to Swift 4 an application that is using Swift 3. I updated the language to use in "Swift language version" and I followed the recommendations made by xCode (explicitly use @objc). Once…
eqtèöck
  • 971
  • 1
  • 13
  • 27
2
votes
2 answers

extend class with IB_DESIGNABLE obj-c

I found IBDesignable and IBInspectable very usefull to bring setter possibility directly to the storyboard. I use it in a swift projet that way import Foundation import UIKit @IBDesignable extension UIView { @IBInspectable var addBorderTop:…
Keuha
  • 295
  • 3
  • 18
2
votes
2 answers

Custom UIButton @IBDesignable

I created a UIButton subclass that looks like a checkmark. Here is the class: import UIKit @IBDesignable class CheckedButton: UIButton { // MARK: - Properties @IBInspectable var checked: Bool = false { didSet { //…
Frederic Adda
  • 5,905
  • 4
  • 56
  • 71
2
votes
1 answer

@IBInspectable to set a Typealias for a Class

I am trying to build a generic UITableViewController with a Realm Results as model. These are my simplified classes: Realm Object: import RealmSwift class Test: Object { dynamic var name = "" } TableViewCell: import UIKit import…
pesch
  • 1,976
  • 2
  • 17
  • 29
2
votes
2 answers

Can't set @IBInspectable computed property in UIView

I'm trying to add an IBInspectable color to UIView, so that I can set it in the storyboard and later use it in code. In this post regarding UITextField I've seen that I can take advantage of extensions and adding a computed property, but I can't…
Andrej
  • 7,266
  • 4
  • 38
  • 57
2
votes
1 answer

@IBInspectable fatal error: unexpectedly found nil while unwrapping an Optional value

I got fatal error: unexpectedly found nil while unwrapping an Optional value when running my app it hangs for the following code
Alaa Aljohani
  • 621
  • 5
  • 5
2
votes
0 answers

Using IBDesignable and IBInspectable on an NSColor Property breaks Xcodes colour picker

I am using an IBInspectable NSColor property to set the background colour of my view but when I use the colour picker in xcode it lets me initially set the value but then when I go to change any other value on the picker it no longer takes effect.…
SacredGeometry
  • 863
  • 4
  • 13
  • 24
2
votes
0 answers

IBInspectable attributes not appearing in Xcode 8 "user defined runtime attributes" area?

I'm running XCode 8.1 and can not get my IBInspectable attributes appearing in Xcode. Any known issues with XCode 8.1 (swift 3) in this area? Or any issues with what I'm trying to do here? Steps: Create a simple IOS app Created the following…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
1 answer

Making UIImage redraw on new position on @IB_Designable

I am creating this IB_Designable class. It is like a slider. See picture. Both elements are created with little stretchable UIImages. I have this red square that is 66x66 pt. This square has to slide in X inside the gray rectangle. I have create…
Duck
  • 34,902
  • 47
  • 248
  • 470
2
votes
0 answers

Is it possible to hide ibinspectable variables of the custom class?

Hide IBInspectable Variables This is how it looks Also I want to know if it is possible to make an enum of strings. I'm working with Swift 2.2 and Swift 3 @IBDesignable class example : some class { @IBInspectable var makeMagic : bool = false …
David Castro
  • 193
  • 1
  • 6
1 2 3
8 9