使用自定义 UIAlertView xCode - 包括 Dialog/Text?

Using Custom UIAlertView xCode - Including Dialog/Text?

所以我一直在寻找一种在 iOS 8.

中将图像和其他内容包含到 UIAlertViews 中的好方法

我最终从 Github 中找到了 this answer, which uses this custom class,有人好心上传了。

效果很好,看起来很棒,但我不确定您实际上是如何在警报中包含对话框或文本的,或者您是如何给它一个标题的(如果可能的话)。

有很多代码需要查看,所以也许我只是遗漏了它,但这是我的 IBAction,其中包括警报中的图片和 shows 它...如何我可以包含标题或一些文字,或两者都包含吗?

- (IBAction)TestButton:(id)sender {
    CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
    [alertView setContainerView:[self createDemoView:@"testImage.png"]];
    [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"Done", nil]];
    [alertView setDelegate:self];
    [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) { [alertView close]; }];
    [alertView setUseMotionEffects:true];
    [alertView setAlpha:0.90];
    [alertView show];
}

希望你们对此有一些经验 class 并且可以帮助我添加一些文字 :D

所以经过一夜的睡眠,我发布了添加文本实际上是多么简单。 您所做的一切,不是为图像添加 UIImageView,而是添加 UITextView 并设置您想要的位置的坐标。在我的例子中,在 UIImageView 下面,然后添加为子视图。

//include Text
UITextView *textViewContent = [[UITextView alloc] initWithFrame:CGRectMake(70, 200, 200, 110)];
textViewContent.text = @"My Text Here";
textViewContent.backgroundColor = nil;
[demoView addSubview:textViewContent];