zoukankan      html  css  js  c++  java
  • iOS提示弹窗

     1 +(void)showMessage:(NSString *)message
     2 {
     3     UIWindow * window = [UIApplication sharedApplication].keyWindow;
     4     UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KscreenWidth, KscreenHeigh)];
     5     view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
     6     [window addSubview:view];
     7     CGRect message_rect = [message boundingRectWithSize:CGSizeMake(window.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]}  context:nil];
     8     
     9     UIView *showview =  [[UIView alloc]init];
    10     showview.backgroundColor = [UIColor whiteColor];
    11     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);
    12     showview.alpha = 1.0f;
    13     showview.layer.cornerRadius = 5.0f;
    14     showview.layer.masksToBounds = YES;
    15     [window addSubview:showview];
    16     
    17     UILabel *label = [[
    18                        UILabel alloc]init];
    19     label.frame = CGRectMake(0, 0, message_rect.size.width, SCREEN_HEIGHT);
    20     label.text = message;
    21     label.textColor = [UIColor blackColor];
    22     label.numberOfLines = 0;
    23     label.textAlignment = 1;
    24     label.backgroundColor = [UIColor clearColor];
    25     label.font = [UIFont systemFontOfSize:15];
    26     [showview addSubview:label];
    27 
    28     [UIView animateWithDuration:2 animations:^{
    29         showview.alpha = 0;
    30         view.alpha = 0;
    31     } completion:^(BOOL finished) {
    32         [showview removeFromSuperview];
    33         [view removeFromSuperview];
    34     }];
    35 }
  • 相关阅读:
    C#中递归算法的总结
    C# 创建错误日志
    获取指定路径下所有PDF文件的总页数
    C# 将文件转为字符串和将字符串转为文件的方法
    如何获得应用程序的物理路径
    C#中获得文件夹下所有文件的两种方法
    C#中加密与解密
    MacOS系统使用Homebrew官方地址报错
    privoxy代理服务器配置
    Nginx 反向代理 502 permission denied 解决
  • 原文地址:https://www.cnblogs.com/kfgcs/p/6387572.html
Copyright © 2011-2022 走看看