类似QQ导航底部显示提示弹窗,能自动消失

来源:互联网 发布:淘宝买家骗局 编辑:程序博客网 时间:2024/06/06 20:39

类似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];    }];
0 0
原创粉丝点击