原理图如下:
- (void)show{
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
UIView *topView = [win.subviews objectAtIndex:0];
[topView addSubview:self];
[UIView animateWithDuration:0.1 animations:^{
[self layoutIfNeeded];
}];
}
- (void)hide{
[UIView animateWithDuration:0.1 animations:^{
self.alpha = 0;
[self layoutIfNeeded];
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
时间: 2024-10-09 20:17:13