Using Custom UIAlertView xCode - Including Dialog/Text?

260 views Asked by At

So I've been searching for a good way to include images and additional stuff into UIAlertViews in iOS 8.

I eventually found this answer, which uses this custom class from Github which someone kindly uploaded.

It works great and looks amazing, but I'm not sure how you actually include dialog or text in the alert or how you give it a title (if it's even possible).

There's a lot of code to look through, so maybe I'm just missing it, but this is my IBAction which includes a picture in the alert and shows it... How can I include a title, or some text, or both?

- (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];
}

Hopefully you guys have some experience with this class and can help me include some text :D

1

There are 1 answers

0
Reanimation On BEST ANSWER

So after a nights sleep, I released how simple it actually is to add text. All you do, instead of adding a UIImageView for the image, you add a UITextView and set the coordinates for the position you want it at. In my case, below the UIImageView, then add as a subview.

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