Is there a specific way to make OverlayView work without resorting to setting the frame on the views? Part of the problem is that there is no superview at the time the constraints are placed. Sample code would be appreciated.
You would need to set constraints on IGOverlayView or set UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth for the autoresizingMask. A constraint or autoresizingMask needs set because the IGOverlayView's size and position is configurable.
I noticed a small bug where, during rotation while the overlay is overlaid, the overlay doesn't recalculate it's frame so it is positioned wrong when rotation finishes. This might be minor on a fast moving overlay, but it does look awkward when it's been up for a while just hanging out in the wrong position.
Oops, never mind the wrapper. That's not necessary. I was doing something wrong when I first started testing. I blame low blood sugar.
Here's what works for me.
-(IGOverlayView*)overlayView
{
if(!_overlayView)
_overlayView = [[IGOverlayView alloc] init];
_overlayView.durationShow = 0.5;
}
return _overlayView;
-(void)createOverlayWithGradient:(UIColor *)topColor bottomColor:(UIColor *)bottomColor title:(NSString *)title message:(NSString *)message
if (_overlayView.isVisible)
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[self performSelector:@selector(dismissOverlay) withObject:nil afterDelay:2.25];
return;
DDLogVerbose(@"%s - subviews:%@", __PRETTY_FUNCTION__, self.overlayView.subviews);
UIView *contentView = [[UIView alloc] init];
contentView.SE_autoLayoutEnabled = YES;
contentView.backgroundColor = [UIColor redColor];
[self.overlayView addSubview:contentView];
[contentView SE_constrainToSize:CGSizeMake(50, 50) priority:1000];
[contentView SE_constrainFailsafeSuperviewInset:0 priority:1000];
[contentView SE_constrainToSuperviewCenteredHorizontally:YES vertically:YES priority:1000];
.....
This works, but let me know if this is what you had in mind...
UIView *autolayoutContainer = [[UIView alloc] init];
[_overlayView addSubview:autolayoutContainer];
autolayoutContainer.frame = self.view.bounds;
autolayoutContainer.clipsToBounds = YES;
autolayoutContainer.backgroundColor = [UIColor clearColor];
UIView *container = [self.overlayView.subviews firstObject];
self.overlayView.backgroundColor = [UIColor orangeColor];
[container addSubview:contentView];