0

可能重复:
UIAlertView 中的图像

我正在实施一个益智游戏。玩家获胜后,我会显示您获胜的警报。但是我想在我的警报视图上添加笑脸。怎么做?

4

1 回答 1

1

用这个

UIAlertView *successAlert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)];

    NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"smile.png"]];
    UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
    [imageView setImage:bkgImg];
    [bkgImg release];
    [path release];

    [successAlert addSubview:imageView];
    [imageView release];

    [successAlert show];
    [successAlert release];

在这里复制表格

于 2012-05-23T05:52:33.817 回答