Reputation: 1238
Hi guys i'm stuck with this problem. I need to create a behavior like this one in the image.
I created a UIView xib (because i need to reuse this view) with a UIProgressView for the 'dark orange' fill and then create an UIView for the indicator with a UILabel in it but i'm unable to move it with setFrame so i was thinking that subclassing an UISlider would be much easier.
What do you think?
This is the code that doesn't work, the .xib uses AutoLayout and now i'm using Xcode 6.
ScoresView *score = [[[NSBundle mainBundle] loadNibNamed:@"scoresView" owner:self options:nil] objectAtIndex:0];
[score.markView setFrame:CGRectMake(score.markView.frame.origin.x + offset, score.markView.frame.origin.y, score.markView.frame.size.width, score.markView.frame.size.height)];
[score.progressView setProgress:0.5];
[score setFrame:viewSize];
[self.scoreScrollView addSubview:score];
Upvotes: 0
Views: 640
Reputation: 62686
Since the views are using auto layout, you must animate the layout constraints, not the frame. You do that by creating an outlet to the constraint and changing its constant.
But it might be easier to not use auto layout on the dark orange view. Build and add it in code. Set its frame origin equal to the light orange view, and set its width equal to progress (0-1) * light orange width.
Upvotes: 1