subivews
叫view A
,view B
,view C
。view A
,其余的views
必须自动向上移动。注意:不在中autolayout
。请说说它的可能性automask
它不会自动运行,您需要进行一些编程,可以尝试以下代码来实现此目的,
//Adding Delete Tap Gesture
-(void)addGestureToSubViews{
for(UIView *view in parent.subviews){
UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deleteAction:)];
[view addGestureRecognizer:gesture];
}
}
-(IBAction)deleteAction:(UITapGestureRecognizer *)sender{
UIView *view=sender.view;
[UIView animateWithDuration:.3 animations:^{
CGRect rect=view.frame;
rect.origin.x=view.superview.frame.size.width;
view.frame=rect;
} completion:^(BOOL finished) {
[self reArrangeSuperView:view.superview withDeletedViewFrame:view.frame];
[view removeFromSuperview];
}];
}
-(void)reArrangeSuperView:(UIView *)superView withDeletedViewFrame:(CGRect)frame{
for(UIView *view in superView.subviews){
CGRect rect=view.frame;
if(rect.origin.y>frame.origin.y){
rect.origin.y=frame.origin.y;
}
[UIView animateWithDuration:.3 animations:^{
view.frame=rect;
}];
}
}
希望对您有所帮助。
干杯。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句