问题描述
- 修改警告信息的宽和高
-
想要将弹出的警告框修改为一个小一点的。-(void)alertMessage1:(NSString*) title:(NSString*) message1 { UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Successfully uploaded!" message:message1 delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil]; }
解决方案
可以创建一个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坐标, 宽, 高)。修改数值应该就可以了。
时间: 2024-08-10 15:22:13