当我按下一个按钮时,我必须显示一个带活动指示的白色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指标
答案 0 :(得分:1)
您可以创建自定义提醒,例如关注(PS:我在工作3小时后开发了此自定义提醒,与iPhone4
,iPhone5
和iPad
兼容) 强>:
-(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
}
答案 1 :(得分:0)
更改活动指标的颜色
在iOS 5.0及更高版本中,您可以在UIActivityIndicatorView上使用setColor:
来设置自定义颜色。
制作自定义提醒视图
创建一个子类 在视图部分顶部绘制正确的白色
答案 2 :(得分:0)
为什么不使用你拍摄的照片? https://github.com/m1entus/WCAlertView
对于ActivityIndicator,您可以使用IB拖出一个并更改其颜色。然后做一些事情:
[activityindicator startanimating];
//put alert code here
// choose when you want to stop the animation:
//[activityindicator stopanimating];