【发布时间】:2011-06-25 14:52:30
【问题描述】:
我想将自定义图像设置为警报视图的背景。如果我将图像视图帧大小设置为静态,则它可以正确显示。但是我已经通过消息内容是动态显示的,所以有时内容很小,有时它会在警报视图中显示大量数据。那么我如何设置取决于警报视图框架的图像视图框架大小尺寸。
这是我的示例代码,
UIAlertView *notesAlert = [[UIAlertView alloc] initWithTitle:@"" message:notes delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
UIImage *alertBoxImage = [UIImage imageNamed:@"AlertViewBG.png"];
UIImageView *_backgroundImageView = [[UIImageView alloc] initWithImage:alertBoxImage];
_backgroundImageView.frame = CGRectMake(0, 0, 282, 130);
_backgroundImageView.contentMode = UIViewContentModeScaleToFill;
[notesAlert addSubview:_backgroundImageView];
[notesAlert sendSubviewToBack:_backgroundImageView];
NSLog(@"The Alert view frame height %f and width %f", notesAlert.frame.size.height, notesAlert.frame.size.width);
// height 0.000000 and width 0.000000
[notesAlert show];
NSLog(@"After showing the Alert view frame height %f and width %f", notesAlert.frame.size.height, notesAlert.frame.size.width);
// height 173.800003 and width 312.399994
看我的屏幕截图:
那么如何设置取决于警报视图框架的图像框架大小? 请帮帮我。 谢谢。
【问题讨论】:
标签: iphone uialertview