0

想知道用较小的窗口初始化我的警报弹出窗口的正确方法是什么

-(void)alertMessage1:(NSString*) title:(NSString*) message1  {

UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Successfully uploaded!" message:message1 delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];

}
4

3 回答 3

1

您应该创建自定义 AlertView 或使用以下之一:

https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=alertview

于 2013-06-29T03:50:27.967 回答
1

您可以按照您的建议创建一个 UIAlertview

UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Title Here" message:@"Message here" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
                    [alert setDelegate:self];
                    [alert show];
                    [alert release];

如果你想调整他们使用的框架

- (void)willPresentAlertView:(UIAlertView *)alertView {
alertView.frame = CGRectMake(20.f, 200.f, 280.f, 93.f);
NSArray *subViewArray = alertView.subviews;
for(int x=0;x<[subViewArray count];x++){
    if([[[subViewArray objectAtIndex:x] class] isSubclassOfClass:[UILabel class]])
    {
        UILabel *label = [subViewArray objectAtIndex:x];
        label.textAlignment = UITextAlignmentLeft;
    }

}

}

在这个alertView.frame = CGRectMake(20.f, 200.f, 280.f, 93.f); CGRectMake(X 位置、Y 位置、宽度、高度)。改变它,你的工作就会完成。

于 2013-06-29T05:08:26.280 回答
0

对于您在评论中提出的更改 UIAlertview 背景颜色的问题, 您可以直接添加这样的背景图像。我不确定你是否可以添加颜色。

UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention" message: @"YOUR MESSAGE HERE", nil) delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[theAlert show];
UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor redColor]];
UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor blueColor]];
UIImage *theImage = [UIImage imageNamed:@"Background.png"];
theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
CGSize theSize = [theAlert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[theAlert layer] setContents:[theImage CGImage]];
于 2013-06-29T08:34:37.800 回答