1

1 つのボタンを押すと、5 秒間、アクティビティ インジケータを含む 1 つの白色の uialertview を表示する必要がありますか? いくつかのコードを見て、次のコードを選択しました。それで十分ですか? アクティビティ インジケーターの色を変更する方法

 myAlertView = [[UIAlertView alloc] initWithTitle:@"Loading" message:@"\n\n"
                                        delegate:self
                               cancelButtonTitle:@""
                               otherButtonTitles:@"OK", nil];  

UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc]
                initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];   
loading.frame=CGRectMake(150, 150, 16, 16);
[myAlertView addSubview:loading];

uiactivity インジケーターを使用して、この画像のようなものが欲しい

ここに画像の説明を入力

4

3 に答える 3

1

次のようなカスタム アラートを作成できます(追記: 3 時間の作業の後にこのカスタム アラートを開発しましたiPhone4iPhone5iPad

-(void)showAlert{


alertViewView = [[UIView alloc]initWithFrame:self.window.frame];

UIImageView *alertBackground = [[UIImageView alloc]initWithFrame:CGRectMake(-200, -200, self.window.frame.size.width*2, self.window.frame.size.height*2)];
//   alertBackground.image = [UIImage imageNamed:@"alertBackGround.png"];
[alertViewView addSubview:alertBackground];

alertBackground.backgroundColor = [UIColor blackColor];
alertBackground.alpha = 0.5;
UIImageView *alertImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.window.frame.size.width/2-310/2, self.window.frame.size.height/2-179/2, 310, 248)];
alertImage.image = [UIImage imageNamed:@"rommanAlertBig.png"];
[alertViewView addSubview:alertImage];[alertBackground release];[alertImage release];


        UIButton *lButton = [UIButton buttonWithType:UIButtonTypeCustom];
        lButton.frame = CGRectMake(self.view.frame.size.width/2-150+40-15, self.view.frame.size.height/2-179/2+118 , 120, 41);
         [lButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [lButton addTarget:self action:@selector(removeAlert) forControlEvents:UIControlEventTouchUpInside];
        [alertViewView addSubview:lButton];


        UIButton *rButton = [UIButton buttonWithType:UIButtonTypeCustom];
        rButton.frame = CGRectMake(self.view.frame.size.width/2-150+170-15, self.view.frame.size.height/2-179/2+118 , 120, 41);
         [rButton setTitle:@"OK" forState:UIControlStateNormal];
        [rButton addTarget:self action:@selector(yesAction) forControlEvents:UIControlEventTouchUpInside];
        [alertViewView addSubview:rButton];





UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(self.window.frame.size.width/2-310/2+30, self.window.frame.size.height/2-179/2+75, 260, 40+69)];
lbl.text = @"Description";
lbl.textColor = [UIColor whiteColor];
lbl.textAlignment  =UITextAlignmentCenter;
lbl.numberOfLines = 0;
lbl.font = [UIFont systemFontOfSize:17.0];
lbl.backgroundColor = [UIColor clearColor];
[alertViewView addSubview:lbl];[lbl release];

[self.window addSubview:alertViewView];
alertViewView.alpha = 0;
[UIView animateWithDuration:0.1 animations:^{alertViewView.alpha = 1.0;}];

alertViewView.layer.transform = CATransform3DMakeScale(0.5, 0.5, 1.0);

CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
bounceAnimation.values = [NSArray arrayWithObjects:
                          [NSNumber numberWithFloat:0.5],
                          [NSNumber numberWithFloat:1.1],
                          [NSNumber numberWithFloat:0.8],
                          [NSNumber numberWithFloat:1.0], nil];
bounceAnimation.duration = 0.3;
bounceAnimation.removedOnCompletion = NO;
[alertViewView.layer addAnimation:bounceAnimation forKey:@"bounce"];

alertViewView.layer.transform = CATransform3DIdentity;


}


-(void)removeAlert{
for (UIView *v in [alertViewView subviews]) {
    [v removeFromSuperview];
}
[alertViewView removeFromSuperview];
[alertViewView release];


}

-(void)yesAction

{ [self removeAlert];
// Your Code here

}
于 2013-05-21T12:45:10.357 に答える
0

写真を撮ったクラスを使用してみませんか?https://github.com/m1entus/WCAlertView

ActivityIndi​​cator については、IB を使用して 1 つをドラッグするだけで、その色を変更できます。次に、次のようにします。

[activityindicator startanimating];

//put alert code here

// choose when you want to stop the animation:
//[activityindicator stopanimating];
于 2013-05-21T12:49:44.007 に答える