iOS UIActivityIndicatorView

-(void) loading:(NSString *)loadingMessage{
    loadingView = [[UIView alloc] initWithFrame:CGRectMake((self.view.frame.size.width-400)/2, (self.view.frame.size.height-200)/2, 400, 200)];
    loadingView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
    loadingView.layer.masksToBounds = YES;
    loadingView.layer.cornerRadius = 15;
    [self.view addSubview:loadingView];
    
    UILabel *message = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, 380, 20)];
    message.text = [NSString stringWithFormat:@"%@",loadingMessage];
    message.textColor = [UIColor whiteColor];
    message.font = [UIFont systemFontOfSize:24.0];
    message.textAlignment = NSTextAlignmentCenter;
    [loadingView addSubview:message];
    
    UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    loading.frame = CGRectMake((400-50)/2, 200-80, 50, 50);
    loading.backgroundColor = [UIColor clearColor];
    [loading startAnimating];
    [loadingView addSubview:loading];
}

//調用
[self loading:@"加載中..."];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章