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 }
  • 相关阅读:
    .net core 3.0中可以使用gRPC了
    Java clone() 浅克隆与深度克隆(转)
    CENTOS下搭建SVN服务器(转)
    设置eclipse不同的workspace共享配置
    在Eclipse添加Android兼容包( v4、v7 appcompat )(转)
    【原创】Nginx+PHP-FPM优化技巧总结(转)
    【汇总】PHP-FPM 配置优化(转)
    nginx File not found 错误(转)
    nginx php-fpm安装配置(转)
    nginx优化(转)
  • 原文地址:https://www.cnblogs.com/kfgcs/p/6387572.html
Copyright © 2011-2022 走看看