gpt4 book ai didi

ios - 我如何添加带有事件指示器的时尚白色 uialertview

转载 作者:行者123 更新时间:2023-11-29 13:13:09 25 4
gpt4 key购买 nike

当我按下一个按钮时,我必须显示一个带有事件指示器的白色 uialertview 5 秒钟?我看到了一些代码,我选择了以下代码,够了吗?我怎样才能改变事件指示器的颜色

 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 指示器的东西

enter image description here

最佳答案

您可以创建一个自定义警报,如下所示(PS:我在工作 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

}

关于ios - 我如何添加带有事件指示器的时尚白色 uialertview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16670083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com