类似QQ无网络时候从导航缓慢弹出提示弹窗的封装
//缓慢进入界面
//显示到导航底部
//渐渐淡出界面
//TipView.h
#import <UIKit/UIKit.h>
@interface TipView : UIView
@property (nonatomic,strong) UILabel *tipLab;
@end
//TipView.m”
#import "TipView.h"
@implementation TipView
-(instancetype)initWithFrame:(CGRect)frame
{
if (self=[super initWithFrame:frame]) {
self.backgroundColor = [UIColor grayColor];
[self createSubViews];
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionMoveIn;
animation.subtype = kCATransitionFromBottom;
[self.layer addAnimation:animation forKey:@"animation"];
}
return self;
}
- (void)createSubViews
{
_tipLab= [[UILabel alloc] init];
_tipLab.text = @"提示的lable";
_tipLab.frame = CGRectMake(15, 0, self.width, self.height);
_tipLab.font = [UIFont systemFontOfSize:13];
[self addSubview:_tipLab];
}
//view的调用
TipView *tipView = [[TipView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, 40)];
UIWindow * window = [UIApplication sharedApplication].keyWindow;
[window addSubview:tipView];
[UIView animateWithDuration:5 animations:^{
tipView.alpha = 0;
} completion:^(BOOL finished) {
[tipView removeFromSuperview];
}];