iOS: xib自定义view的模版小记

#import "CustomView.h"

@interface CustomView(Private)

@property (nonatomic, weak) IBOutlet UIButton *btnNew;
@property (nonatomic, weak) IBOutlet UIButton *btnEdit;
@property (nonatomic, weak) IBOutlet UIButton *btnDelete;
@property (nonatomic, weak) IBOutlet UIButton *btnCancel;

@end

@implementation CustomView

+ (CustomView *)instanceWithFrame:(CGRect)frame
{
    CustomView *view = (CustomView *)[[NSBundle mainBundle] loadNibNamed:@"CustomViewXib" owner:nil options:nil][0];
    view.frame = frame;
    return view;
}


//1
- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        
    }
    return self;
}

//2
- (void)awakeFromNib {
    [super awakeFromNib];
}

//3
- (void)willMoveToSuperview:(UIView *)newSuperview {
    if (newSuperview) {
        
    }
}

//4
- (void)layoutSubviews {
    [super layoutSubviews];
    
    
}

@end


你可能感兴趣的:(iOS: xib自定义view的模版小记)