UIAlertController

  • 修改文字大小 颜色
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"选择照片" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *takePhoto = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];

    UIAlertAction *chooseAlbum = [UIAlertAction actionWithTitle:@"相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];

    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

    }];

    [alertController addAction:takePhoto];
    [alertController addAction:chooseAlbum];
    [alertController addAction:cancel];


    //修改title
    NSMutableAttributedString *titleStr = [[NSMutableAttributedString alloc] initWithString:@"选择照片"];
    [titleStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#999999"] range:NSMakeRange(0, 4)];
    [titleStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, 4)];
    [alertController setValue:titleStr forKey:@"attributedTitle"];

    //修改message
    NSMutableAttributedString *messageStr = [[NSMutableAttributedString alloc] initWithString:@""];
    [messageStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 0)];
    [messageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 0)];
    [alertController setValue:messageStr forKey:@"attributedMessage"];

    // 修改Action
    [takePhoto setValue:[UIColor colorWithHexString:@"#EF9707"] forKey:@"titleTextColor"];
    [chooseAlbum setValue:[UIColor colorWithHexString:@"#EF9707"] forKey:@"titleTextColor"];
    [cancel setValue:[UIColor colorWithHexString:@"#EF9707"] forKey:@"titleTextColor"];

    [self presentViewController:alertController animated:YES completion:nil];

results matching ""

    No results matching ""