有時我們需要在alterView上放置圖片,來清楚地標示些資訊,以下是實作方式
根據前一篇的例子,加上兩張圖片來做顯示
很簡當,只需在alter上加入UIImageView就可以了
- (void) alertViewAction1
{
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message 1......\nMessage 2......" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(180, 10, 100, 100)];
NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"1001.png"]];
UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
[imageView setImage:bkgImg];
[alert1 addSubview:imageView];
UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
NSString *path2 = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"1002.png"]];
UIImage *bkgImg2 = [[UIImage alloc] initWithContentsOfFile:path2];
[imageView2 setImage:bkgImg2];
[alert1 addSubview:imageView2];
[alert1 show];
}

沒有留言:
張貼留言