Is it possible to show an Image in UIAlertView?

后端 未结 9 457
别跟我提以往
别跟我提以往 2020-11-29 02:01

Is it possible to add image in an UIAlertView, like showing an image from the plist file?

9条回答
  •  暖寄归人
    2020-11-29 02:28

    Using pure layout pod:

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Hello"
                                                                             message:nil
                                                                      preferredStyle:UIAlertControllerStyleAlert];
    UIImage *image = // target image here;
    CGSize size = image.size;
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(leftMargin, topMargin, size.width, size.height)];
    imageView.image = image;
    [alertController.view addSubview:imageView];
    [imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:leftMargin];
    [imageView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:topMargin];
    [imageView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:rightMargin];
    [imageView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:bottomMargin];
    [imageView autoSetDimension:ALDimensionWidth toSize:size.width];
    [imageView autoSetDimension:ALDimensionHeight toSize:size.height];
    // add desired actions here
    [self presentViewController:alertController animated:YES completion:nil];
    

提交回复
热议问题