ibinspectable

Create max character length in UITextField using IBInspectable [duplicate]

冷暖自知 提交于 2020-06-17 09:45:14
问题 This question already has answers here : Limiting characters and character length in textField(_:shouldChangeCharactersInRange:replacementString:) (2 answers) Closed 13 days ago . I want to create a max length to my textfield with IBInspectable , I see a answer to this on a question here but I'm getting an error saying Expression type '()' is ambiguous without more context , My code was import UIKit private var __maxLengths = [UITextField: Int]() extension UITextField { @IBInspectable var

Create custom action in a class for use in Interface Builder

ぃ、小莉子 提交于 2020-01-15 09:31:30
问题 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: Selector? The action is something and the target is object . Now I want in Interface Builder to have 'Send Action' link / connection available for something and to be able to make connection to a @IBAction method to some class (for example the controller of the

Interface builder agent crashes when accessing @IBInspectable UIImage

夙愿已清 提交于 2020-01-14 10:33:12
问题 I'm implementing a custom view by subclassing UIView and using @IBInspectable for some of my variables. Two of them are UIImage. If I try to access one of them in the code, the interface builder crashes with the following message: file:///PathToMyProject/MyProject/Pod/Classes/UI/View/MyView.xib: error: IB Designables: Failed to update auto layout status: The agent crashed and file:///PathToMyProject/MyProject/Pod/Classes/UI/View/MyView.xib: error: IB Designables: Failed to render instance of

How to set a max limit for an IBInspectable Int

為{幸葍}努か 提交于 2019-12-30 08:59:43
问题 I am using an IBInspectable Int in Swift to choose between 4 four shapes (0-3), however it is possible in the storyboard editor to set a value greater than 3 and less than 0, which stops the IBDesignable system working. Is it possible to set a min and max limit of what values can be set in the storyboard editor? let SHAPE_CROSS = 0 let SHAPE_SQUARE = 1 let SHAPE_CIRCLE = 2 let SHAPE_TRIANGLE = 3 @IBInspectable var shapeType: Int = 0 @IBInspectable var shapeSize: CGFloat = 100.0 @IBInspectable

EXC_BAD_ACCESS Using IBInspectable

那年仲夏 提交于 2019-12-20 05:50:18
问题 I am trying to use IBInspectable to add borders to my views. extension UIView { private func getBorder(integer: Int) -> UIRectEdge { if integer == 1 { return .top } else if integer == 2 { return .left } else if integer == 3 { return .right } else if integer == 4 { return .bottom } return .all } @IBInspectable var border: Int? { get { return self.border } set (value) { self.border = value for v in addBorder(edges: self.getBorder(integer: self.border!)) { self.addSubview(v) } } } @IBInspectable

@IBInspectable not updating Story Board

≡放荡痞女 提交于 2019-12-11 12:23:01
问题 My custom button below works fine on the iOS Simulator - when I set a rotation in Interface Builder it rotates the button when I run the app. However, I can't see the rotation in the Story Board - it just shows the button without applying the transformation. It doesn't matter if I do the transformation inside the drawRect method - same result. import Foundation import UIKit @IBDesignable class CustomButton: UIButton { @IBInspectable var rotation: CGFloat = 0.0 { didSet { self.transform =

How to create segment control like IBInspectable properties?

强颜欢笑 提交于 2019-12-11 04:29:19
问题 I want to create custom control like segment control But i'm not able to understand how to create this kind of Segment IBInspectable properties. i mean it's elements increasing according to Segments . as i know there is no support of array in @IBInspectable . 回答1: You can't create that type of @IBInspectable (yet), but... You can define a String variable as an @IBInspectable var, and add multiple lines to it. Then have a didSet method split the string into an array which you use internally

Can't set @IBInspectable computed property in UIView

筅森魡賤 提交于 2019-12-11 02:02:22
问题 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 make it work for UIView. I get a crash: Failed to set (additionalColor1) user defined inspected property on (UIView): [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key additionalColor1. Any idea what's causing the

IBInspectable with Cocoa Touch Framework not working? (code attached)

蹲街弑〆低调 提交于 2019-12-10 13:17:07
问题 I can not seem to get the "titleText" IBInspectable attribute working. I have a simple framework view with a UILabel which I create an IBInspectable variable "titleText". I note the inspectable "layer" variables work as expected, but not my custom "titleText" which is supposed to update the main view using this framework. Issues are: Interface Builder not updating the titleLabel? (i.e. at design time) i.e. I'm expecting that this should, just like it is working for the "layer" items. At Run

Can you add IBDesignable properties to UIView using categories/extensions?

空扰寡人 提交于 2019-12-09 02:34:48
问题 For those that don't know what I'm talking about, Xcode 6.0 added new features, IBDesignable and IBInspectable. When you tag your custom views with IBInspectable properties, those properties show up in the Attributes Inspector in IB. Likewise, when you tag a custom UIView subclass with IBDesignable, Xcode compiles your views and invokes the code to render your view objects right in the Xcode window so you can see what they look like. The technique for adding IBDesignable and IBInspectable