I am building a custom progress bar (subclass of UIView). I add an UIImageView to the UIView that uses repeating images to display the progress. The view is added to the storyboard and I can get it to display just fine, however if I try to change the frame then it only displays whatever is shown in the storyboard file (i.e. if the storyboard view has a yellow background, but the code of the uiview subclass changes it to green, if I try to change the frame of the UIImageView in the code to reflect the current progress then it defaults back to the yellow background)
I tried using these with no luck:
[self updateConstraints];
[self layoutSubviews];
UPDATE
I know I need to setup a constraint for use with autolayout. However, it needs to be done programmatically as I am creating the subclassed UIView this way. Here is the code I am trying, I know I am close but can't quite get it to work:
[self addConstraint:
[NSLayoutConstraint constraintWithItem:self.progressView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationLessThanOrEqual
toItem:nil
attribute:NSLayoutAttributeWidth
multiplier:1
constant:progressWidth]];
[UIView animateWithDuration:3 animations:^{
[self.progressView layoutIfNeeded];
}];