UIActivityIndicatorView or similar

前端 未结 6 1094
攒了一身酷
攒了一身酷 2021-01-30 18:44


(source: tumblr.com)

Can anyone tell me how to achieve such loading message? is it some variation of UIActivityIndicatorView? thanks peter

6条回答
  •  梦谈多话
    2021-01-30 19:23

    Something similar to the following in your initWithFrame of your custom subclassed UIView:

        _hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
        _hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        _hudView.clipsToBounds = YES;
        _hudView.layer.cornerRadius = 10.0;
    
        _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        _activityIndicatorView.frame = CGRectMake(65, 40, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height);
        [_hudView addSubview:_activityIndicatorView];
        [_activityIndicatorView startAnimating];
    
        _captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
        _captionLabel.backgroundColor = [UIColor clearColor];
        _captionLabel.textColor = [UIColor whiteColor];
        _captionLabel.adjustsFontSizeToFitWidth = YES;
        _captionLabel.textAlignment = NSTextAlignmentCenter;
        _captionLabel.text = @"Loading...";
        [_hudView addSubview:_captionLabel];
    
        [self addSubview:_hudView];
    

提交回复
热议问题