I created uiview custom class and implemented in Main View Controller
-(KPHomeChartCategory *)chartCategory {
if (!_chartCategory) {
_chartCategory = [[KPHomeChartCategory alloc] init];
_chartCategory.delegate = self;
_chartCategory.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_chartCategory];
[self.chartCategory.topAnchor constraintEqualToAnchor:self.topAnchor constant:-7.5].active = YES;
[self.chartCategory.rightAnchor constraintEqualToAnchor:self.rightAnchor].active = YES;
self.chartCategoryLeftAnchor = [self.chartCategory.leftAnchor constraintEqualToAnchor:self.rightAnchor];
self.chartCategoryLeftAnchor.active = YES;
[self.chartCategory.heightAnchor constraintEqualToConstant:100].active = YES;
}
return _chartCategory;
}
I animated uiview custom class (KPHomeChartCategory) constraints in this way
-(void)openPanelTagAnimation {
self.chartCategoryLeftAnchor.active = NO;
self.chartCategoryLeftAnchor = [self.chartCategory.leftAnchor constraintEqualToAnchor:self.rightAnchor constant:-self.frame.size.width +105];
self.chartCategoryLeftAnchor.active = YES;
[UIView animateWithDuration:.6 delay:0 usingSpringWithDamping:1 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.customSwitch.alpha = 0;
[self layoutIfNeeded];
} completion:nil];
}
Now if you look at the video, you will notice that the first time I show customView, my collection view is shown from above but afterwards the animation seems to be perfectly straightforward ... can you make me understand why this thing?
Video Link
VIDEO ANIMATION
Why my animation first starts from top to bottom and only then is linear ? (the linear animation from right to left is the correct one and should be the first time the custom view is animated)