ibdesignable

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

why the autolayout is not updated if I use IBDesignable file when i run the app?

柔情痞子 提交于 2019-12-06 11:03:26
问题 here is the project of this problem in the google drive: https://drive.google.com/file/d/1Js0t-stoerWy8O8uIOJl_bDw-bnWAZPr/view?usp=sharing I make a custom navigation bar (the red view in the picture below) using IBDesignable code below. I want, if the iPhone has top notch like iPhone X, iPhone XR, then the height of custom navigation bar is 88, otherwise the height is 64. I make an IBDesignable code so I can reuse this code import UIKit @IBDesignable class CustomParentNavigationBarView:

Get the type name of derived type in a static method of base class or extension Swift

巧了我就是萌 提交于 2019-12-06 06:03:40
TL:DR Paste this into Swift playground: import UIKit public protocol NibLoadable { static var nibName: String { get } } extension NibLoadable where Self: UIView { public static var nibName: String { return String(describing: self) } func printName(){ print(Self.nibName) } } public class Shoes: UIView, NibLoadable { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) printName() } override init(frame: CGRect) { super.init(frame: frame) printName() } } public class Cake: Shoes { } let cake = Cake() // this line prints 'Shoes' How do i make it print Cake , not Shoes ? Full

Layer transform matrix (CATransform3D, etc.) but with IBDesignable?

人盡茶涼 提交于 2019-12-05 16:09:35
This class will put perspective on an upright image. It works perfectly BUT does not work live in Storyboard with IBDesignable. Which is very sad. Is it possible to use CATransform3D and the like for live display on Storyboard with IBDesignable?? // Twist.swift .. twist on Y, perspective from the left import UIKit @IBDesignable class Twist:UIViewController { @IBInspectable var perspective:CGFloat = 0.5 // -1 to 1 @IBOutlet var im:UIView! // the image you want to twist on y override func prepareForInterfaceBuilder() { twist(perspective) } override func viewDidAppear(animated: Bool) { twist

Generic IBDesginables UIView extension

百般思念 提交于 2019-12-04 19:30:55
I would like to create generic extension for class to add some designables functionality to any UIView subclass and by this avoid adding functionality to all subclasses. So, would be nice to add extension for UIView which conforms to protocol SomeProtocol (It's empty because it is just a tag to mark classes which I want functionality to be added). Then just add that protocol in any UIView subclass where I want that functionality to be implemented like this: protocol SomeProtocol { //empty } class BCBorderedView : UIView, SomeProtocol { //empty } class BCBorderedSearch: UISearchBar,

why the autolayout is not updated if I use IBDesignable file when i run the app?

梦想与她 提交于 2019-12-04 17:54:29
here is the project of this problem in the google drive: https://drive.google.com/file/d/1Js0t-stoerWy8O8uIOJl_bDw-bnWAZPr/view?usp=sharing I make a custom navigation bar (the red view in the picture below) using IBDesignable code below. I want, if the iPhone has top notch like iPhone X, iPhone XR, then the height of custom navigation bar is 88, otherwise the height is 64. I make an IBDesignable code so I can reuse this code import UIKit @IBDesignable class CustomParentNavigationBarView: UIView { override func awakeFromNib() { super.awakeFromNib() self.setHeight() } override func

Instantiate view from nib throws error

人走茶凉 提交于 2019-12-04 15:56:43
问题 I tried to make @IBDesignable UIView subclass following this (link) tutorial. First custom view goes fine. But when I try to make another one, I have errors. First I got failed to update auto layout status: the agent crashed and Failed to render instance of ... . Somehow I started to be able to biuld and run project with these errors, but then I get new error - EXC_BAD_ACCESS ... on line let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView . Here is whole method: func

Instantiate view from nib throws error

北城余情 提交于 2019-12-03 22:39:37
I tried to make @IBDesignable UIView subclass following this ( link ) tutorial. First custom view goes fine. But when I try to make another one, I have errors. First I got failed to update auto layout status: the agent crashed and Failed to render instance of ... . Somehow I started to be able to biuld and run project with these errors, but then I get new error - EXC_BAD_ACCESS ... on line let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView . Here is whole method: func loadViewFromNib() -> UIView { let bundle = NSBundle(forClass: self.dynamicType) let nib = UINib(nibName:

IBDesignable never finishes updating UITableViewCell in storyboard

拈花ヽ惹草 提交于 2019-12-03 17:02:39
问题 This is a similar question to this but not quite the same. I have created a subclass of UITableViewCell which references a custom nib and marked it as @IBDesignable. Changes that are made both in code and from the .xib file display correctly in the simulator and on a device but not in the storyboard. import UIKit @IBDesignable class TextFieldTableViewCell: UITableViewCell { var view: UIView! required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setup() } override init(style:

IBDesignable Build Failed

[亡魂溺海] 提交于 2019-12-03 15:08:04
问题 I have Created IBDesignable and IBInspectable custom class to give shadow and corner radius for view But When I assign Designable class to view , I get Designable Build Failed This is my code import Foundation import UIKit @IBDesignable class DesignableView: UIView { } @IBDesignable class DesignableButton: UIButton { } @IBDesignable class DesignableLabel: UILabel { } @IBDesignable class DesignableTableView: UITableView { } extension UIView { @IBInspectable var cornerRadius: CGFloat { get {