ibinspectable

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 {

【Swift】UILabel 设置内边距

余生颓废 提交于 2019-12-03 05:54:23
【Swift】UILabel 设置内边距 前言   对应一个曾经开发 Android 的人来说,没有这些基础属性简直令人发指,还是表喷这个,认真写代码 - - # 声明   欢迎转载,但请保留文章原始出处:)   博客园:http://www.cnblogs.com   农民伯伯: http://over140.cnblogs.com 正文 class UILabelPadding : UILabel { private var padding = UIEdgeInsetsZero @IBInspectable var paddingLeft: CGFloat { get { return padding.left } set { padding.left = newValue } } @IBInspectable var paddingRight: CGFloat { get { return padding.right } set { padding.right = newValue } } @IBInspectable var paddingTop: CGFloat { get { return padding.top } set { padding.top = newValue } } @IBInspectable var paddingBottom: CGFloat {

IBDesignable Build Failed

谁说胖子不能爱 提交于 2019-12-03 04:48:47
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 { return layer.cornerRadius } set { layer.cornerRadius = newValue } } @IBInspectable var borderWidth:

How to set default values for IBInspectable in Objective-C?

倖福魔咒の 提交于 2019-12-03 03:49:33
问题 I know default values of IBInspectable-properties can be set as: @IBInspectable var propertyName:propertyType = defaultValue in Swift. But how do I achieve a similar effect in Objective-C so that I can have default value of some property set to something in Interface Builder? 回答1: Since IBInspectable values are set after initWithCoder: and before awakeFromNib: , you can set the defaults in initWithCoder: method. @interface MyView : UIView @property (copy, nonatomic) IBInspectable NSString

How to set default values for IBInspectable in Objective-C?

泄露秘密 提交于 2019-12-02 17:24:12
I know default values of IBInspectable-properties can be set as: @IBInspectable var propertyName:propertyType = defaultValue in Swift. But how do I achieve a similar effect in Objective-C so that I can have default value of some property set to something in Interface Builder? rintaro Since IBInspectable values are set after initWithCoder: and before awakeFromNib: , you can set the defaults in initWithCoder: method. @interface MyView : UIView @property (copy, nonatomic) IBInspectable NSString *myProp; @property (assign, nonatomic) BOOL createdFromIB; @end @implementation MyView - (id

EXC_BAD_ACCESS Using IBInspectable

旧时模样 提交于 2019-12-02 09:25:53
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 var borderColor: UIColor? { get { return self.borderColor } set (value) { self.borderColor = value /

How to set a max limit for an IBInspectable Int

情到浓时终转凉″ 提交于 2019-12-01 05:24:33
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 var shapeColor: UIColor? There's no way to limit what a user can input in Storyboard. However, you

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

跟風遠走 提交于 2019-12-01 02:25:30
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 attributes to custom views is pretty much identical in Swift and Objective-C. IBInspectable properties

Some sort of “global” for IBDesignables?

烈酒焚心 提交于 2019-12-01 01:41:44
问题 In storyboard have a UIView, with a constraint for example "0.1" proportional height. Imagine you have a similar constraint "0.1", on views in many different scenes. Say you want to change the value 0.1 to 0.975. You have to change it individually everywhere. Is there some way to make a sort of "global value" , using @IBInspectable and/or constraints? So that you can change them all at once , and see the results all at once in storyboard . (Of course, at run-time you could propagate these in

How to control an UIView's rounded corners separately using @IBInspectable in Swift 3?

落爺英雄遲暮 提交于 2019-11-30 15:50:42
问题 Here is my current code: override func viewDidLoad() { super.viewDidLoad() let rect = Draw(frame: CGRect( origin: CGPoint(x: 50, y: 50), size: CGSize(width: 100, height: 100))) self.view.addSubview(rect) } 回答1: Use this custom class, basically you need create a bezier path, using lines and quad curves, handling every corner with values in @IBInspectable properties. This is the code // // CornerView.swift // UIViewCornerRounded // // Created by Reinier Melian on 21/07/2017. // Copyright © 2017