Skip to content

Instantly share code, notes, and snippets.

@sbrocket
Created December 30, 2009 22:59
Show Gist options
  • Select an option

  • Save sbrocket/266483 to your computer and use it in GitHub Desktop.

Select an option

Save sbrocket/266483 to your computer and use it in GitHub Desktop.
- (void)loadNibAndInitializeWithFrame:(CGRect)finalFrame {
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"AppDisplayView" owner:self options:nil];
UIView *containerView = [nibObjects lastObject];
NSArray *subviewsToAdd = [containerView subviews];
self.frame = containerView.frame;
for (UIView *view in subviewsToAdd) {
[self addSubview:view];
}
self.tag = containerView.tag;
self.alpha = containerView.alpha;
self.opaque = containerView.opaque;
self.hidden = containerView.hidden;
self.contentMode = containerView.contentMode;
self.clipsToBounds = containerView.clipsToBounds;
self.contentStretch = containerView.contentStretch;
self.backgroundColor = containerView.backgroundColor;
self.userInteractionEnabled = containerView.userInteractionEnabled;
self.clearsContextBeforeDrawing = containerView.clearsContextBeforeDrawing;
self.autoresizesSubviews = containerView.autoresizesSubviews;
self.autoresizingMask = containerView.autoresizingMask;
if (!CGRectEqualToRect(finalFrame, CGRectZero)) {
self.frame = finalFrame;
}
}
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
[self loadNibAndInitializeWithFrame:frame];
}
return self;
}
- (id)initWithCoder:(NSCoder*)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
[self loadNibAndInitializeWithFrame:self.frame];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment