-(void)click

{

    NSString *showMsg = @"点击我,开始提示";

    int width = showMsg.length * 20;

    

    UIWindow *window = [UIApplication sharedApplication].keyWindow;

    

    UIView *tipView = [[UIView alloc]init];

    tipView.frame = CGRectMake((window.frame.size.width/2)-width/2, (window.frame.size.height/2)-30, width, 50);

    tipView.backgroundColor = [UIColor blackColor];

    

    UILabel *labelView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, width, 50)];

    labelView.text = showMsg;

    labelView.textColor = [UIColor whiteColor];

    labelView.font = [UIFont systemFontOfSize:15];

    labelView.textAlignment = kCTCenterTextAlignment;

    [tipView addSubview:labelView];

    

    [window addSubview:tipView];

    

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

    

}

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
  • 2021-09-12
  • 2022-12-23
  • 2022-01-20
  • 2021-05-05
相关资源
相似解决方案