GIF показывает проблему. Приведенный ниже код показывает, как я добавляю вид в супервизор и восходящий из нижней части супервизора. Этот код работает отлично в iOS 9, а не в iOS 10.UIVIew анимация не работает должным образом в iOS 10
Анимация слайд-анимации не подходит. Он выходит с правой стороны и делает угол вместо прямой снизу.
Пожалуйста, помогите мне решить эту проблему.
+ (ControlsView *)addArticleControlsToView:(UIView *)view bellowSubview:(UIView *)subview{
ControlsView *articleControls = [[[NSBundle mainBundle] loadNibNamed:@"ControlsView" owner:self options:nil]firstObject];
[view insertSubview:articleControls belowSubview:subview];
NSDictionary *viewsDict = @{@"currentView":articleControls};
[articleControls setTranslatesAutoresizingMaskIntoConstraints:NO];
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"H:|-0-[currentView]-0-|"] options:0 metrics:@{} views:viewsDict];
NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[currentView(189)]-0-|" options:0 metrics:@{} views:viewsDict];
[view addConstraints:horizontalConstraints];
[view addConstraints:verticalConstraints];
[articleControls setBackgroundColor:[UIColor clearColor]];
articleControls.viewBottomConstraint.constant = -189;
[articleControls layoutIfNeeded];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:articleControls action:@selector(slideSheetDown)];
[articleControls addGestureRecognizer:tapGesture];
return articleControls;
}
- (void)slideSheetUp {
[UIView animateWithDuration:0.5 animations:^{
self.viewBottomConstraint.constant = 0;
self.scrollViewBottomConstraint.constant = 189;
[self setBackgroundColor:[UIColor clearColor]];
[self.scrollView.superview layoutIfNeeded];
[self layoutIfNeeded];
}];
}
Не обновлять константу ограничения в блоке анимации. – Desdenova
@Desdenova Удалена и работает, но как ее оживить сейчас в iOS 10? –
Сохраните бит 'layoutIfNeeded' в блоке. Просто не устанавливайте в нем константы. – Desdenova