ibdesignable

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

雨燕双飞 提交于 2020-01-02 06:31:30
问题 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

IBDesignables and traitCollection in live rendering

有些话、适合烂在心里 提交于 2019-12-31 00:57:25
问题 I am building my custom UIControl, a custom button built as an IBDesignable, which needs to change based on the size class in which it is being displayed. I have a method -setupForTraitCollection, which looks like this: func setupForTraitCollection() { switch(traitCollection.horizontalSizeClass, traitCollection.verticalSizeClass) { case (.Regular, _): // iPad - not compressed design compressed = false default: // iPhone - compressed design compressed = true } } This code works great when

IBDesignable Errors When Adding to Tests Target

眉间皱痕 提交于 2019-12-29 03:55:29
问题 I have a simple UIButton subclass that implements IBDesignable with an IBInspectable var: @IBDesignable class Button: UIButton { @IBInspectable var borderColor: UIColor = UIColor.whiteColor() { didSet { layer.borderColor = borderColor.CGColor } } } I am not using this within a framework and it is working in Interface Builder as intended, however, once I add this subclass to my Tests target, it stops rendering live and I get the following errors: Main.storyboard: error: IB Designables: Failed

Xcode IBDesignablesAgentCocoaTouch loads CPU infinitely?

爱⌒轻易说出口 提交于 2019-12-23 12:14:44
问题 I have a .xib file with extensive usage of IBDesignable views. As view grown I noticed constant CPU load. Now, my view is really big and when I open it in interface builder, ActivityMonitor show this: . It continues even if I leave .xib file and go to code. The only solution to stop it is to close, then open Xcode and don't open .xib file until it is really necessary. My rough assumption is that Xcode continues compiling my project/views in background to maintain IBDesignable views in actual

When I set the image to IBImageView, get build failed

◇◆丶佛笑我妖孽 提交于 2019-12-23 04:28:38
问题 My IBImageView is like this: In LMLCommonIBImageView.h : #import <UIKit/UIKit.h> IB_DESIGNABLE @interface LMLCommonIBImageView : UIImageView @property (nonatomic, assign)IBInspectable CGFloat borderWidth; @property (nonatomic, strong)IBInspectable UIColor *borderColor; @property (nonatomic, assign)IBInspectable CGFloat cornerRadius; @end In LMLCommonIBImageView.m file: #import "LMLCommonIBImageView.h" @implementation LMLCommonIBImageView - (void)setBorderWidth:(CGFloat)borderWidth { if

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

谁都会走 提交于 2019-12-22 18:39:09
问题 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

@IBDesignable view doesn't draw background color inside Interface Builder

狂风中的少年 提交于 2019-12-22 05:14:49
问题 I'm curious why doesn't this set the backgroundColor to red? @IBDesignable class CustomLabel: UIView { let view = UIView() func setup() { backgroundColor = UIColor.red view.backgroundColor = UIColor.green view.frame = CGRect(x: 0, y: 0, width: 50, height: 50) addSubview(view) } override init(frame: CGRect) { super.init(frame: frame) setup() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setup() } } This is the result. And this is what I expect it to look like. 回答1:

Generic IBDesginables UIView extension

与世无争的帅哥 提交于 2019-12-22 00:36:32
问题 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 }

Make a fixed size UIView, like UISwitch (using IBDesignable)

余生颓废 提交于 2019-12-20 18:09:11
问题 When I'm using this guide to create a view that is designed in a XIB, reusable from within a storyboard using the IBDesignable attribute on my UIView subclass, how do I make it have a fixed size, and have its resizing behavior match that of a view like UISwitch? With "resizing behavior" I also mean while designing in interface builder. 回答1: You could override intrinsicContentSize() in your UIView subclass. Then you won't need to supply height and width constraints in the interface builder.

Making Gradient Background in Swift - The Right Way

大憨熊 提交于 2019-12-20 07:45:09
问题 This is my code for a gradient background. When I apply it on my view, it hides all my stuff on that VC, like it's on the front and everything else is pushed back. How can I make a gradient view that is not interfering with my elements? I'm using @IBDesignable just to see how is it looking in Storyboard. import UIKit @IBDesignable class GradientView: UIView { private let gradientLayer = CAGradientLayer() var color1 = ColorPalette.GrdTop var color2 = ColorPalette.GrdBottom override init(frame: