[英]iOS : Resizing subview by removing a subview
subivews
view A
, 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;
}];
}
}
希望对您有所帮助。
干杯。
为此,您必须在属性检查器中隐藏视图,并且要向上推哪个视图,应设置视图的-contentoffset属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.