#pragma mark - 减少点击
-(void)btnReduceClick{
[UIView animateWithDuration:0.5f
delay:0.0f
usingSpringWithDamping:0.7f
initialSpringVelocity:5.0f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
NSArray *subviewArrays = self.stackStars.arrangedSubviews;
if(subviewArrays.count != 0){
UIView* view = self.stackStars.arrangedSubviews.lastObject;
[self.stackStars removeArrangedSubview:view];
[view removeFromSuperview];
}
} completion:^(BOOL finished) {
}];
}
#pragma mark - 增加点击
-(void)btnAddClick{
[UIView animateWithDuration:0.5f
delay:0.0f
usingSpringWithDamping:0.7f
initialSpringVelocity:5.0f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_star"]];
imageView.contentMode = UIViewContentModeCenter;
[self.stackStars addArrangedSubview:imageView];
} completion:^(BOOL finished) {
}];
}
参考文献:
iOS9之UIStackView体验,无需任何约束,这才是真正的自动布局,快到不能呼吸
An Introduction to Stack Views in iOS 9 and Xcode 7
iOS 9: UIStackView入门