I want to add progress bar in swift iOS 8 UIAlertController. Is this possible? Is there any way to subclass UIAlertController and add progres bar and connect some delegate funct
A solution with auto layout:
UIAlertController *alertCtr = [UIAlertController alertControllerWithTitle:@"Test" message:@"50%" preferredStyle:UIAlertControllerStyleAlert];
[alertCtr addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
// Do things
}]];
UIView *alertView = alertCtr.view;
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectZero];
progressView.progress = 0.5;
progressView.translatesAutoresizingMaskIntoConstraints = false;
[alertView addSubview:progressView];
NSLayoutConstraint *bottomConstraint = [progressView.bottomAnchor constraintEqualToAnchor:alertView.bottomAnchor];
[bottomConstraint setActive:YES];
bottomConstraint.constant = -45; // How to constraint to Cancel button?
[[progressView.leftAnchor constraintEqualToAnchor:alertView.leftAnchor] setActive:YES];
[[progressView.rightAnchor constraintEqualToAnchor:alertView.rightAnchor] setActive:YES];
[self presentViewController:alertCtr animated:true completion:nil];