Skip to content

Instantly share code, notes, and snippets.

- (void)floatIntoWindow {
if(self.superview == self.window) return;
CGRect newFrame = [self.superview convertRect:self.frame toView:nil];
[self.window addSubview:self];
self.transform = [self transformForCurrentInterfaceOrientation];
self.frame = newFrame;
}
- (void)unfloatIntoView:(UIView *)newSuperview {
CGRect newFrame = [newSuperview convertRect:view.frame fromView:nil];
[newSuperview addSubview:view];
view.frame = newFrame;
CGRect newFrame = [view.superview convertRect:view.frame toView:nil];
[view.window addSubview:view];
view.frame = newFrame;