iOS提示弹窗

释放双眼,带上耳机,听听看~!
+(void)showMessage:(NSString *)message
{
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KscreenWidth, KscreenHeigh)];
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
    [window addSubview:view];
    CGRect message_rect = [message boundingRectWithSize:CGSizeMake(window.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]}  context:nil];
    
    UIView *showview =  [[UIView alloc]init];
    showview.backgroundColor = [UIColor whiteColor];
    showview.frame = CGRectMake((window.frame.size.width-message_rect.size.width)/2, (window.frame.size.height-SCREEN_HEIGHT)/2, message_rect.size.width, SCREEN_HEIGHT);
    showview.alpha = 1.0f;
    showview.layer.cornerRadius = 5.0f;
    showview.layer.masksToBounds = YES;
    [window addSubview:showview];
    
    UILabel *label = [[
                       UILabel alloc]init];
    label.frame = CGRectMake(0, 0, message_rect.size.width, SCREEN_HEIGHT);
    label.text = message;
    label.textColor = [UIColor blackColor];
    label.numberOfLines = 0;
    label.textAlignment = 1;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont systemFontOfSize:15];
    [showview addSubview:label];

    [UIView animateWithDuration:2 animations:^{
        showview.alpha = 0;
        view.alpha = 0;
    } completion:^(BOOL finished) {
        [showview removeFromSuperview];
        [view removeFromSuperview];
    }];
}

 

人已赞赏
iOS文章

iOS图片拉伸技巧

2019-11-17 13:57:29

iOS文章

iOS sha1加密算法

2019-11-17 14:46:21

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索