IB_DESIGNABLE和IBInspectable应用
来源:互联网 发布:海贼无双3数据地址 编辑:程序博客网 时间:2024/06/04 18:48
#import <UIKit/UIKit.h>IB_DESIGNABLE@interface UIView (HKPIBInspectable)@property(nonatomic,assign) IBInspectable CGFloat cornerRadius;@property(nonatomic,assign) IBInspectable CGFloat borderWidth;@property(nonatomic,assign) IBInspectable UIColor *borderColor;@property(nonatomic,assign) IBInspectable CGFloat defineValue;@end
#import "UIView+HKPIBInspectable.h"#import <objc/runtime.h>@implementation UIView (HKPIBInspectable)-(void)setCornerRadius:(CGFloat)cornerRadius{ self.layer.masksToBounds = YES; self.layer.cornerRadius = cornerRadius;}-(void)setBorderColor:(UIColor *)borderColor{ self.layer.borderColor = borderColor.CGColor;}-(void)setBorderWidth:(CGFloat)borderWidth{ self.layer.borderWidth = borderWidth;}-(void)setDefineValue:(CGFloat)defineValue{ objc_setAssociatedObject(self, @selector(defineValue), @(defineValue),OBJC_ASSOCIATION_ASSIGN);}-(CGFloat)cornerRadius{ return self.layer.cornerRadius;}-(CGFloat)borderWidth{ return self.layer.borderWidth;}-(UIColor *)borderColor{ return [UIColor colorWithCGColor:self.layer.borderColor];}-(CGFloat)defineValue{ return [objc_getAssociatedObject(self, @selector(defineValue)) floatValue];}@end
无效图如下:(备注:虽然已经新建UIView的分类,可是没有效果出来.)
有效图如下:(备注:新建了customView继承于UIView,效果出来了)
0 0
- IB_DESIGNABLE和IBInspectable应用
- iOS IBInspectable和IB_DESIGNABLE
- IB_DESIGNABLE和IBInspectable
- IBInspectable和IB_DESIGNABLE
- IB_DESIGNABLE 和 IBInspectable
- 神奇的IB_DESIGNABLE和IBInspectable
- 神奇的IB_DESIGNABLE和IBInspectable
- IBInspectable 和IB_DESIGNABLE动态刷新IB
- iOS 神奇的IB_DESIGNABLE和IBInspectable
- IB_DESIGNABLE 与IBInspectable 补充
- iOS学习笔记:神奇的IB_DESIGNABLE和IBInspectable
- iOS SDK详解之IBInspectable和IB_DESIGNABLE-Storyboad动态刷新
- iOS SDK详解之IBInspectable和IB_DESIGNABLE-Storyboad动态刷新
- iOS SDK详解之IBInspectable和IB_DESIGNABLE-Storyboad动态刷新
- iOS SDK详解之IBInspectable和IB_DESIGNABLE-Storyboad动态刷新(自定义控件)
- IB_DESIGNABLE 设计UIView子类 和IBInspectable 设置UIView自定义属性, storyboard,xib中加圆角
- iOS进阶之巧用IBInspectable属性和IB_DESIGNABLE宏定义
- IOS开发—IB_Designable & IBInspectable介绍
- 计算机启动过程
- display:none和visibility:none的区别
- 8天学通MongoDB——第四天 索引操作
- 欢迎使用CSDN-markdown编辑器
- 8天学通MongoDB——第五天 主从复制
- IB_DESIGNABLE和IBInspectable应用
- 微信支付全部详细流程
- Struts2学习之旅(6)
- 8天学通MongoDB——第六天 分片技术
- 什么场景下将MySQL替换为HBase
- (模板题)poj 3041 Asteroids(二分图的最大匹配匈牙利算法)
- 用户和组
- link和import的区别
- 8天学通MongoDB——第七天 运维技术