在一个xib 中调用另外一个xib
.h 文件
@property (strong, nonatomic) UIView *view;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *label_title;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, assign) BOOL select;
.m 文件
#import "SFStatusSelectVIew.h"
@implementation SFStatusSelectVIew
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self addSubview:self.view];
}
return self;
}
// 获取xib中的view
- (UIView *)view{
if (!_view) {
_view = [[NSBundle mainBundle] loadNibNamed:@"SFStatusSelectVIew" owner:self options:nil].lastObject;
}
return _view;
}
- (void)layoutSubviews{
[super layoutSubviews];
//设置大小
self.view.frame = self.bounds;
}
- (void)awakeFromNib{
[super awakeFromNib];
_select = NO;
self.layer.cornerRadius = 5;
self.layer.masksToBounds = YES;
}
- (void)setTitle:(NSString *)title{
_title = title;
self.label_title.text = title;
}
- (void)setSelect:(BOOL)select{
_select = select;
if (select) {
self.imageView.image = [UIImage imageNamed:@"icon_check"];
}else{
self.imageView.image = [UIImage imageNamed:@"icon_select"];
}
}
在使用 使用的地方