如何在我的警报视图上添加笑脸?

时间:2012-05-23 05:49:02

标签: iphone

  

可能重复:
  Image in UIAlertView

我正在实施益智游戏。在玩家赢了之后,我会显示你赢了的警报。但有了这个我想在我的警报视图上添加笑脸。怎么做?

1 个答案:

答案 0 :(得分: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];

复制表单here