{"id":4977,"date":"2014-03-30T17:25:42","date_gmt":"2014-03-30T17:25:42","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/uiviews-border-color-in-interface-builder-doesnt-work-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:25:42","modified_gmt":"2014-03-30T17:25:42","slug":"uiviews-border-color-in-interface-builder-doesnt-work-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/uiviews-border-color-in-interface-builder-doesnt-work-collection-of-common-programming-errors\/","title":{"rendered":"UIView&#39;s border color in Interface builder doesn&#39;t work?-Collection of common programming errors"},"content":{"rendered":"<p>Here&#8217;s a quick way to overcome this. Categories&#8230;<\/p>\n<pre><code>@interface UIView (IBAppearance)\n\n@property (nonatomic, strong) UIColor *borderColor;\n\n@end\n<\/code><\/pre>\n<p>You don&#8217;t have to store it, it&#8217;s just nice so you can query later. The important thing is taking the value and assigning the UIColor&#8217;s CGColor to the layer.<\/p>\n<pre><code>#import \n\n#define BORDER_COLOR_KEYPATH @\"borderColor\"\n\n@implementation UIView (IBAppearance)\n\n- (void)setBorderColor:(UIColor *)borderColor {\n    UIColor *bc = objc_getAssociatedObject(self, BORDER_COLOR_KEYPATH);\n    if(bc == borderColor) return;\n    else {\n        objc_setAssociatedObject(self, BORDER_COLOR_KEYPATH, borderColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);\n        self.layer.borderColor = [borderColor CGColor];\n    }\n}\n\n- (UIColor *)borderColor {\n    return objc_getAssociatedObject(self, BORDER_COLOR_KEYPATH);\n}\n\n@end\n<\/code><\/pre>\n<p>Of course, in the Interface Builder you&#8217;re not setting the value on <code>layer.borderColor<\/code>, rather just on <code>borderColor<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a quick way to overcome this. Categories&#8230; @interface UIView (IBAppearance) @property (nonatomic, strong) UIColor *borderColor; @end You don&#8217;t have to store it, it&#8217;s just nice so you can query later. The important thing is taking the value and assigning the UIColor&#8217;s CGColor to the layer. #import #define BORDER_COLOR_KEYPATH @&#8221;borderColor&#8221; @implementation UIView (IBAppearance) &#8211; (void)setBorderColor:(UIColor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4977","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4977"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4977\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}