为xib添加属性设置

新建两个扩展类

//
//  UIView+XibConfiguration.h
//  waimaibiz
//
//  Created by luningning02 on 16/11/25.
//  Copyright © 2016年 meituan. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (XibConfiguration)

@property (nonatomic, assign) IBInspectable UIColor *LayerColor;
@property (nonatomic, assign) IBInspectable CGFloat  LayerWidth;
@property (nonatomic, assign) IBInspectable CGFloat  LayerRadius;

@property (nonatomic, assign) IBInspectable CGSize   ShadowOffset;
@property (nonatomic, assign) IBInspectable CGFloat  ShadowRadius;
@property (nonatomic, assign) IBInspectable CGFloat  ShadowOpacity;
@property (nonatomic, assign) IBInspectable UIColor *ShadowColor;

@end

 

//
//  UIView+XibConfiguration.m
//  waimaibiz
//
//  Created by luningning02 on 16/11/25.
//  Copyright © 2016年 meituan. All rights reserved.
//

#import "UIView+XibConfiguration.h"

@implementation UIView (XibConfiguration)

-(UIColor*)borderUIColor {
    return [UIColor colorWithCGColor:self.layer.borderColor];
}
-(void)setLayerColor:(UIColor *)LayerColor_ {
    self.layer.borderColor = LayerColor_.CGColor;
}
- (UIColor *)LayerColor {
    return [UIColor colorWithCGColor:self.layer.borderColor];
}

- (void)setLayerWidth:(CGFloat)LayerWidth_ {
    self.layer.borderWidth = LayerWidth_;
    self.layer.allowsEdgeAntialiasing = YES;// 解决layer.border.width随着view的放大,会出现锯齿化的问题(iOS7.0)
}
- (CGFloat)LayerWidth {
    return self.layer.borderWidth;
}

- (void)setLayerRadius:(CGFloat)LayerRadius_ {
    self.layer.cornerRadius = LayerRadius_;
}
- (CGFloat)LayerRadius {
    return self.layer.cornerRadius;
}

- (void)setShadowOffset:(CGSize)ShadowOffset_ {
    self.layer.shadowOffset = ShadowOffset_;
}
- (CGSize)ShadowOffset {
    return self.layer.shadowOffset;
}

- (void)setShadowRadius:(CGFloat)ShadowRadius_ {
    self.layer.shadowRadius = ShadowRadius_;
}
- (CGFloat)ShadowRadius {
    return self.layer.shadowRadius;
}

- (void)setShadowOpacity:(CGFloat)ShadowOpacity_ {
    self.layer.shadowOpacity = ShadowOpacity_;
}
- (CGFloat)ShadowOpacity {
    return self.layer.shadowOpacity;
}

- (void)setShadowColor:(UIColor *)ShadowColor_ {
    self.layer.shadowColor = ShadowColor_.CGColor;
}
- (UIColor *)ShadowColor {
    return [UIColor colorWithCGColor:self.layer.shadowColor];
}

@end

 

 

运行成功之后就可以在xib上看见属性设置的框框了

 

 

 

转载于:https://www.cnblogs.com/luningning0901/p/6101837.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值