到目前为止,我在StePopView.m文件中所做的是:
+(instancetype)loadFromXib{
return [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil][0];
}
-(void)awakeFromNib{
[super awakeFromNib];
//configure my view
self.backgroundColor = [[UIColor colorWithWebStr:@"050205"] colorWithAlphaComponent:0.33];
}
//when move to superView, call show method to show a pop view with animation
-(void)didMoveToSuperview{
[self show];
}
-(void)show{
//show a pop view with animation
}
当我在superView中使用此弹出视图时:
StePopView* popView = [StePopView loadFromXib];
popView.frame.bounds = self.bouds;
[self addSubView:popView]
这是一个更好的编码吗?什么是更好的代码,为什么?提前致谢!